diff --git a/.gitignore b/.gitignore
index 3a8146ae84db2d4f2ec5be44853f1d861b5ce5c4..d69de3deae4cbe1dff23fd0f22704f6b4f5e40ed 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,13 +18,17 @@ doc/html/
 doc/latex/
 doc/man/
 doc/Doxyfile
-examples/test
-examples/test_fixdt
-examples/test_fixdt_mpi
-examples/test_mindt
-examples/test_mindt_mpi
-examples/test_mpi
-examples/test_single
+examples/swift
+examples/swift_fixdt
+examples/swift_fixdt_mpi
+examples/swift_mindt
+examples/swift_mindt_mpi
+examples/swift_mpi
+
+tests/testGreetings
+tests/testReading
+tests/input.hdf5
+tests/testSingle
 
 m4/libtool.m4
 m4/ltoptions.m4
diff --git a/Makefile.am b/Makefile.am
index 946534d512007f514eb0c67c2489f22b5bb362c7..9d4f6371b7aa37a1750c5fb8dbed17f9ff48442e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,6 @@
 
 # This file is part of SWIFT.
-# Coypright (c) 2012 pedro.gonnet@durham.ac.uk.
+# Copyright (c) 2012 pedro.gonnet@durham.ac.uk.
 #               2015 matthieu.schaller@durham.ac.uk.
 # 
 # This program is free software: you can redistribute it and/or modify
diff --git a/examples/BigCosmoVolume/makeIC.py b/examples/BigCosmoVolume/makeIC.py
index d5d5392f07671cfc529b76bcb3d00c3f50d3cf52..c4699b5616a634456c245cc33c01987580da4728 100644
--- a/examples/BigCosmoVolume/makeIC.py
+++ b/examples/BigCosmoVolume/makeIC.py
@@ -1,6 +1,6 @@
 ###############################################################################
  # This file is part of SWIFT.
- # Coypright (c) 2015 Matthieu Schaller (matthieu.schaller@durham.ac.uk)
+ # Copyright (c) 2015 Matthieu Schaller (matthieu.schaller@durham.ac.uk)
  # 
  # This program is free software: you can redistribute it and/or modify
  # it under the terms of the GNU Lesser General Public License as published
diff --git a/examples/BigPerturbedBox/makeIC_fcc.py b/examples/BigPerturbedBox/makeIC_fcc.py
index b21cb61f9d6ef9678eeddcc45e07908fb79a4fb0..92bfd9ce24e0018c33c2f68455869ced35b845fa 100644
--- a/examples/BigPerturbedBox/makeIC_fcc.py
+++ b/examples/BigPerturbedBox/makeIC_fcc.py
@@ -1,6 +1,6 @@
 ###############################################################################
  # This file is part of SWIFT.
- # Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+ # Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
  #                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
  # 
  # This program is free software: you can redistribute it and/or modify
diff --git a/examples/CosmoVolume/getIC.sh b/examples/CosmoVolume/getIC.sh
index ebee5e63d53d17019d3d8ba2c58e7bed26ff2641..5b951fc247006f0378bcee2b74a9619b7b1acc7d 100755
--- a/examples/CosmoVolume/getIC.sh
+++ b/examples/CosmoVolume/getIC.sh
@@ -1,2 +1,2 @@
 #!/bin/bash
-wget http://www.dur.ac.uk/pedro.gonnet/cosmoVolume.hdf5
+wget http://icc.dur.ac.uk/~jlvc76/Files/SWIFT/cosmoVolume.hdf5
diff --git a/examples/GreshoVortex/makeIC.py b/examples/GreshoVortex/makeIC.py
index 324dcb65b21527f4e3868571d08fe7a0c9ff98a1..533199869ee325dd75831410f3e9f1181ae30ebd 100644
--- a/examples/GreshoVortex/makeIC.py
+++ b/examples/GreshoVortex/makeIC.py
@@ -1,6 +1,6 @@
 ###############################################################################
  # This file is part of SWIFT.
- # Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+ # Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
  #                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
  # 
  # This program is free software: you can redistribute it and/or modify
diff --git a/examples/GreshoVortex/solution.py b/examples/GreshoVortex/solution.py
index a3937d1d144975c8f0023f1b310ace06cbf6f6b2..5b282caf2d7f3311ddb595781fed74c51bb4819f 100644
--- a/examples/GreshoVortex/solution.py
+++ b/examples/GreshoVortex/solution.py
@@ -1,6 +1,6 @@
 ###############################################################################
  # This file is part of SWIFT.
- # Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+ # Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
  #                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
  # 
  # This program is free software: you can redistribute it and/or modify
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 9d4fd5951374d249e76980689d629079749b2c8f..38ba3e7dbf5f904709683ae9ba883c83831f2000 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -1,6 +1,6 @@
 
 # This file is part of SWIFT.
-# Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+# Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
 #                    Matthieu Schaller (matthieu.schaller@durham.ac.uk).
 #
 # This program is free software: you can redistribute it and/or modify
@@ -29,45 +29,40 @@ MPI_LIBS = $(METIS_LIBS) $(MPI_THREAD_LIBS)
 MPI_FLAGS = -DWITH_MPI $(METIS_INCS)
 
 # Set-up the library
-bin_PROGRAMS = test test_fixdt test_mindt test_single
+bin_PROGRAMS = swift swift_fixdt swift_mindt
 
 # Build MPI versions as well?
 if HAVEMPI
-bin_PROGRAMS += test_mpi test_fixdt_mpi test_mindt_mpi
+bin_PROGRAMS += swift_mpi swift_fixdt_mpi swift_mindt_mpi
 endif
 
-# Sources for test
-test_SOURCES = test.c
-test_CFLAGS = $(MYFLAGS) $(AM_CFLAGS) -DENGINE_POLICY="engine_policy_multistep | engine_policy_keep | engine_policy_setaffinity"
-test_LDADD =  ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS) $(HDF5_LIBS)
+# Sources for swift
+swift_SOURCES = main.c
+swift_CFLAGS = $(MYFLAGS) $(AM_CFLAGS) -DENGINE_POLICY="engine_policy_multistep | engine_policy_keep | engine_policy_setaffinity"
+swift_LDADD =  ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS) $(HDF5_LIBS)
 
-# Sources for test_fixdt
-test_fixdt_SOURCES = test.c
-test_fixdt_CFLAGS = $(MYFLAGS) $(AM_CFLAGS) -DENGINE_POLICY="engine_policy_fixdt | engine_policy_keep | engine_policy_setaffinity"
-test_fixdt_LDADD =  ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS) $(HDF5_LIBS)
+# Sources for swift_fixdt
+swift_fixdt_SOURCES = main.c
+swift_fixdt_CFLAGS = $(MYFLAGS) $(AM_CFLAGS) -DENGINE_POLICY="engine_policy_fixdt | engine_policy_keep | engine_policy_setaffinity"
+swift_fixdt_LDADD =  ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS) $(HDF5_LIBS)
 
-# Sources for test_mindt
-test_mindt_SOURCES = test.c
-test_mindt_CFLAGS = $(MYFLAGS) $(AM_CFLAGS) -DENGINE_POLICY="engine_policy_keep | engine_policy_setaffinity"
-test_mindt_LDADD =  ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS) $(HDF5_LIBS)
+# Sources for swift_mindt
+swift_mindt_SOURCES = main.c
+swift_mindt_CFLAGS = $(MYFLAGS) $(AM_CFLAGS) -DENGINE_POLICY="engine_policy_keep | engine_policy_setaffinity"
+swift_mindt_LDADD =  ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS) $(HDF5_LIBS)
 
-# Sources for test_mpi
-test_mpi_SOURCES = test.c
-test_mpi_CFLAGS = $(MYFLAGS) $(AM_CFLAGS) $(MPI_FLAGS) -DENGINE_POLICY="engine_policy_multistep | engine_policy_keep"
-test_mpi_LDADD =  ../src/.libs/libswiftsim_mpi.a $(HDF5_LDFLAGS) $(HDF5_LIBS) $(MPI_LIBS)
+# Sources for swift_mpi
+swift_mpi_SOURCES = main.c
+swift_mpi_CFLAGS = $(MYFLAGS) $(AM_CFLAGS) $(MPI_FLAGS) -DENGINE_POLICY="engine_policy_multistep | engine_policy_keep"
+swift_mpi_LDADD =  ../src/.libs/libswiftsim_mpi.a $(HDF5_LDFLAGS) $(HDF5_LIBS) $(MPI_LIBS)
 
-# Sources for test_fixdt_mpi
-test_fixdt_mpi_SOURCES = test.c
-test_fixdt_mpi_CFLAGS = $(MYFLAGS) $(AM_CFLAGS) $(MPI_FLAGS) -DENGINE_POLICY="engine_policy_fixdt | engine_policy_keep"
-test_fixdt_mpi_LDADD =  ../src/.libs/libswiftsim_mpi.a $(HDF5_LDFLAGS) $(HDF5_LIBS) $(MPI_LIBS)
+# Sources for swift_fixdt_mpi
+swift_fixdt_mpi_SOURCES = main.c
+swift_fixdt_mpi_CFLAGS = $(MYFLAGS) $(AM_CFLAGS) $(MPI_FLAGS) -DENGINE_POLICY="engine_policy_fixdt | engine_policy_keep"
+swift_fixdt_mpi_LDADD =  ../src/.libs/libswiftsim_mpi.a $(HDF5_LDFLAGS) $(HDF5_LIBS) $(MPI_LIBS)
 
-# Sources for test_mindt_mpi
-test_mindt_mpi_SOURCES = test.c
-test_mindt_mpi_CFLAGS = $(MYFLAGS) $(AM_CFLAGS) $(MPI_FLAGS) -DENGINE_POLICY="engine_policy_keep"
-test_mindt_mpi_LDADD =  ../src/.libs/libswiftsim_mpi.a $(HDF5_LDFLAGS) $(HDF5_LIBS) $(MPI_LIBS)
-
-# Sources for test_single
-test_single_SOURCES = test_single.c
-test_single_CFLAGS = $(MYFLAGS) $(AM_CFLAGS)
-test_single_LDADD =  ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS) $(HDF5_LIBS)
+# Sources for swift_mindt_mpi
+swift_mindt_mpi_SOURCES = main.c
+swift_mindt_mpi_CFLAGS = $(MYFLAGS) $(AM_CFLAGS) $(MPI_FLAGS) -DENGINE_POLICY="engine_policy_keep"
+swift_mindt_mpi_LDADD =  ../src/.libs/libswiftsim_mpi.a $(HDF5_LDFLAGS) $(HDF5_LIBS) $(MPI_LIBS)
 
diff --git a/examples/PertubedBox/makeIC.py b/examples/PertubedBox/makeIC.py
index fe32c6f10a0f836cfc351c87730fd6a32882bad8..a5e831eca02463d287ce2c7748eb780ef66aeb33 100644
--- a/examples/PertubedBox/makeIC.py
+++ b/examples/PertubedBox/makeIC.py
@@ -1,6 +1,6 @@
 ###############################################################################
  # This file is part of SWIFT.
- # Coypright (c) 2013 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+ # Copyright (c) 2013 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
  #                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
  # 
  # This program is free software: you can redistribute it and/or modify
@@ -63,7 +63,7 @@ for i in range(L):
             v[index,1] = 0.
             v[index,2] = 0.
             m[index] = mass
-            h[index] = 2.251 * boxSize / L
+            h[index] = 1.1255 * boxSize / L
             u[index] = internalEnergy
             ids[index] = index
             
diff --git a/examples/SedovBlast/makeIC.py b/examples/SedovBlast/makeIC.py
index abddc803bc6bcb92a0c44eb5ae4e2977a0281aca..f3ed3288306a1ff7bb0387896a7e4e0f803a1f35 100644
--- a/examples/SedovBlast/makeIC.py
+++ b/examples/SedovBlast/makeIC.py
@@ -1,6 +1,6 @@
 ###############################################################################
  # This file is part of SWIFT.
- # Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+ # Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
  #                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
  # 
  # This program is free software: you can redistribute it and/or modify
@@ -67,7 +67,7 @@ for i in range(L):
             v[index,1] = 0.
             v[index,2] = 0.
             m[index] = mass
-            h[index] = 2.251 / 2 * boxSize / L
+            h[index] = 1.1255 * boxSize / L
             u[index] = internalEnergy
             ids[index] = index
             if sqrt((x - boxSize/2.)**2 + (y - boxSize/2.)**2 + (z - boxSize/2.)**2) < 2.01 * boxSize/L:
diff --git a/examples/SedovBlast/makeIC_fcc.py b/examples/SedovBlast/makeIC_fcc.py
index 7e684504095e76c39e92f9b2f954b71aa573fb22..8a5d50031d06247afdd9b51ab9fe43bcca87a963 100644
--- a/examples/SedovBlast/makeIC_fcc.py
+++ b/examples/SedovBlast/makeIC_fcc.py
@@ -1,6 +1,6 @@
 ###############################################################################
  # This file is part of SWIFT.
- # Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+ # Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
  #                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
  # 
  # This program is free software: you can redistribute it and/or modify
@@ -70,7 +70,7 @@ for i in range(L):
                 v[index,1] = 0.
                 v[index,2] = 0.
                 m[index] = mass
-                h[index] = 2.251 / 2 * hbox
+                h[index] = 1.1255 * hbox
                 u[index] = internalEnergy
                 ids[index] = index
                 if sqrt((x - boxSize/2.)**2 + (y - boxSize/2.)**2 + (z - boxSize/2.)**2) < 1.2 * hbox:
diff --git a/examples/SedovBlast/rdf.py b/examples/SedovBlast/rdf.py
index 52b834f3947d1f992093dad9916a6164d5b3b0fa..7f932cc814dc36e14e1bef52e33cf5ed1f527dfd 100644
--- a/examples/SedovBlast/rdf.py
+++ b/examples/SedovBlast/rdf.py
@@ -1,6 +1,6 @@
 ###############################################################################
  # This file is part of SWIFT.
- # Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+ # Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
  #                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
  # 
  # This program is free software: you can redistribute it and/or modify
@@ -29,7 +29,7 @@ from numpy import *
 
 # Input values?
 if len(sys.argv) < 3 :
-    print "Useage: " , sys.argv[0] , " <filename> <nr. bins>"
+    print "Usage: " , sys.argv[0] , " <filename> <nr. bins>"
     exit()
     
 # Get the input arguments
diff --git a/examples/SedovBlast/solution.py b/examples/SedovBlast/solution.py
index 947c9dde5a02cea1f0edcbc60b67f0e3490625c2..9335e22bdd76585e8d53d3dba9f9a435197f92fc 100644
--- a/examples/SedovBlast/solution.py
+++ b/examples/SedovBlast/solution.py
@@ -1,6 +1,6 @@
 ###############################################################################
  # This file is part of SWIFT.
- # Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+ # Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
  #                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
  # 
  # This program is free software: you can redistribute it and/or modify
diff --git a/examples/SodShock/makeIC.py b/examples/SodShock/makeIC.py
index bfd1ede773d0cec42c8b5d0e3a75223fd3abdb5d..8405b192697580e5d9bc586bba1c6fe1265552cf 100644
--- a/examples/SodShock/makeIC.py
+++ b/examples/SodShock/makeIC.py
@@ -1,6 +1,6 @@
 ###############################################################################
  # This file is part of SWIFT.
- # Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+ # Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
  #                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
  # 
  # This program is free software: you can redistribute it and/or modify
diff --git a/examples/SodShock/rhox.py b/examples/SodShock/rhox.py
index 36771c5c0d9dcdec99403249ea8a7bb1a4bc58c6..70493be3728cdeb27409a79f616fa3ec5bb9cdfd 100644
--- a/examples/SodShock/rhox.py
+++ b/examples/SodShock/rhox.py
@@ -1,6 +1,6 @@
 ###############################################################################
  # This file is part of SWIFT.
- # Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+ # Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
  #                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
  # 
  # This program is free software: you can redistribute it and/or modify
@@ -29,7 +29,7 @@ from numpy import *
 
 # Input values?
 if len(sys.argv) < 3 :
-    print "Useage: " , sys.argv[0] , " <filename> <nr. bins>"
+    print "Usage: " , sys.argv[0] , " <filename> <nr. bins>"
     exit()
     
 # Get the input arguments
diff --git a/examples/SodShock/solution.py b/examples/SodShock/solution.py
index a5a1364d90d4af12f3ac051e23748d6228592258..39f25c625232eee9bae0300339955f775f3b46ed 100644
--- a/examples/SodShock/solution.py
+++ b/examples/SodShock/solution.py
@@ -1,6 +1,6 @@
 ###############################################################################
  # This file is part of SWIFT.
- # Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+ # Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
  #                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
  # 
  # This program is free software: you can redistribute it and/or modify
diff --git a/examples/UniformBox/makeIC.py b/examples/UniformBox/makeIC.py
index 2600d79a4a70de3e69fb76b82e11f6a4b72a73d2..9f5e3fd7eeafcc6db824a668fd7fdb11c7b472f5 100644
--- a/examples/UniformBox/makeIC.py
+++ b/examples/UniformBox/makeIC.py
@@ -1,6 +1,6 @@
 ###############################################################################
  # This file is part of SWIFT.
- # Coypright (c) 2013 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+ # Copyright (c) 2013 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
  #                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
  # 
  # This program is free software: you can redistribute it and/or modify
@@ -74,7 +74,7 @@ ds = grp.create_dataset('Masses', (numPart,1), 'f')
 ds[()] = m
 m = zeros(1)
 
-h = full((numPart, 1), 2.251 * boxSize / L)
+h = full((numPart, 1), 1.1255 * boxSize / L)
 ds = grp.create_dataset('SmoothingLength', (numPart,1), 'f')
 ds[()] = h
 h = zeros(1)
diff --git a/examples/test.c b/examples/main.c
similarity index 52%
rename from examples/test.c
rename to examples/main.c
index fb3e4c24f8c8cba0f0e74220f1a7cee7933cda68..fe1a209ca4acf84e76e453a35033846702513ef3 100644
--- a/examples/test.c
+++ b/examples/main.c
@@ -56,493 +56,8 @@
 #define ENGINE_POLICY engine_policy_none
 #endif
 
-/**
- * @brief Mapping function to draw a specific cell (gnuplot).
- */
-
-void map_cells_plot(struct cell *c, void *data) {
-
-  int depth = *(int *)data;
-  double *l = c->loc, *h = c->h;
-
-  if (c->depth <= depth) {
-
-    printf("%.16e %.16e %.16e\n", l[0], l[1], l[2]);
-    printf("%.16e %.16e %.16e\n", l[0] + h[0], l[1], l[2]);
-    printf("%.16e %.16e %.16e\n", l[0] + h[0], l[1] + h[1], l[2]);
-    printf("%.16e %.16e %.16e\n\n\n", l[0], l[1] + h[1], l[2]);
-
-    printf("%.16e %.16e %.16e\n", l[0], l[1], l[2] + h[2]);
-    printf("%.16e %.16e %.16e\n", l[0] + h[0], l[1], l[2] + h[2]);
-    printf("%.16e %.16e %.16e\n", l[0] + h[0], l[1] + h[1], l[2] + h[2]);
-    printf("%.16e %.16e %.16e\n\n\n", l[0], l[1] + h[1], l[2] + h[2]);
-
-    printf("%.16e %.16e %.16e\n", l[0], l[1], l[2]);
-    printf("%.16e %.16e %.16e\n", l[0], l[1] + h[1], l[2]);
-    printf("%.16e %.16e %.16e\n", l[0], l[1] + h[1], l[2] + h[2]);
-    printf("%.16e %.16e %.16e\n\n\n", l[0], l[1], l[2] + h[2]);
-
-    printf("%.16e %.16e %.16e\n", l[0] + h[0], l[1], l[2]);
-    printf("%.16e %.16e %.16e\n", l[0] + h[0], l[1] + h[1], l[2]);
-    printf("%.16e %.16e %.16e\n", l[0] + h[0], l[1] + h[1], l[2] + h[2]);
-    printf("%.16e %.16e %.16e\n\n\n", l[0] + h[0], l[1], l[2] + h[2]);
-
-    printf("%.16e %.16e %.16e\n", l[0], l[1], l[2]);
-    printf("%.16e %.16e %.16e\n", l[0], l[1], l[2] + h[2]);
-    printf("%.16e %.16e %.16e\n", l[0] + h[0], l[1], l[2] + h[2]);
-    printf("%.16e %.16e %.16e\n\n\n", l[0] + h[0], l[1], l[2]);
-
-    printf("%.16e %.16e %.16e\n", l[0], l[1] + h[1], l[2]);
-    printf("%.16e %.16e %.16e\n", l[0], l[1] + h[1], l[2] + h[2]);
-    printf("%.16e %.16e %.16e\n", l[0] + h[0], l[1] + h[1], l[2] + h[2]);
-    printf("%.16e %.16e %.16e\n\n\n", l[0] + h[0], l[1] + h[1], l[2]);
-
-    if (!c->split) {
-      for (int k = 0; k < c->count; k++)
-        printf("0 0 0 %.16e %.16e %.16e\n", c->parts[k].x[0], c->parts[k].x[1],
-               c->parts[k].x[2]);
-      printf("\n\n");
-    }
-    /* else
-        for ( int k = 0 ; k < 8 ; k++ )
-            if ( c->progeny[k] != NULL )
-                map_cells_plot( c->progeny[k] , data ); */
-  }
-}
-
-/**
- * @brief Mapping function for checking if each part is in its box.
- */
-
-/* void map_check ( struct part *p , struct cell *c , void *data ) {
-
-    if ( p->x[0] < c->loc[0] || p->x[0] > c->loc[0]+c->h[0] ||
-         p->x[0] < c->loc[0] || p->x[0] > c->loc[0]+c->h[0] ||
-         p->x[0] < c->loc[0] || p->x[0] > c->loc[0]+c->h[0] )
-        printf( "map_check: particle %i is outside of its box.\n" , p->id );
-
-    } */
-
-/**
- * @brief Mapping function for neighbour count.
- */
-
-void map_cellcheck(struct cell *c, void *data) {
-
-  int k, *count = (int *)data;
-  struct part *p;
-
-  __sync_fetch_and_add(count, c->count);
-
-  /* Loop over all parts and check if they are in the cell. */
-  for (k = 0; k < c->count; k++) {
-    p = &c->parts[k];
-    if (p->x[0] < c->loc[0] || p->x[1] < c->loc[1] || p->x[2] < c->loc[2] ||
-        p->x[0] > c->loc[0] + c->h[0] || p->x[1] > c->loc[1] + c->h[1] ||
-        p->x[2] > c->loc[2] + c->h[2]) {
-      printf(
-          "map_cellcheck: particle at [ %.16e %.16e %.16e ] outside of cell [ "
-          "%.16e %.16e %.16e ] - [ %.16e %.16e %.16e ].\n",
-          p->x[0], p->x[1], p->x[2], c->loc[0], c->loc[1], c->loc[2],
-          c->loc[0] + c->h[0], c->loc[1] + c->h[1], c->loc[2] + c->h[2]);
-      error("particle out of bounds!");
-    }
-  }
-}
-
-/**
- * @brief Mapping function for maxdepth cell count.
- */
-
-void map_maxdepth(struct cell *c, void *data) {
-
-  int maxdepth = ((int *)data)[0];
-  int *count = &((int *)data)[1];
-
-  // printf( "%e\n" , p->count );
-
-  if (c->depth == maxdepth) *count += 1;
-}
-
-/**
- * @brief Mapping function for neighbour count.
- */
-
-void map_count(struct part *p, struct cell *c, void *data) {
-
-  double *wcount = (double *)data;
-
-  // printf( "%i %e %e\n" , p->id , p->count , p->count_dh );
-
-  *wcount += p->density.wcount;
-}
-
-void map_wcount_min(struct part *p, struct cell *c, void *data) {
-
-  struct part **p2 = (struct part **)data;
-
-  if (p->density.wcount < (*p2)->density.wcount) *p2 = p;
-}
-
-void map_wcount_max(struct part *p, struct cell *c, void *data) {
-
-  struct part **p2 = (struct part **)data;
-
-  if (p->density.wcount > (*p2)->density.wcount) *p2 = p;
-}
-
-void map_h_min(struct part *p, struct cell *c, void *data) {
-
-  struct part **p2 = (struct part **)data;
-
-  if (p->h < (*p2)->h) *p2 = p;
-}
-
-void map_h_max(struct part *p, struct cell *c, void *data) {
-
-  struct part **p2 = (struct part **)data;
-
-  if (p->h > (*p2)->h) *p2 = p;
-}
-
-/**
- * @brief Mapping function for neighbour count.
- */
-
-void map_icount(struct part *p, struct cell *c, void *data) {
-
-  // int *count = (int *)data;
-
-  // printf( "%i\n" , p->icount );
-
-  // *count += p->icount;
-}
-
-/**
- * @brief Mapping function to print the particle position.
- */
-
-void map_dump(struct part *p, struct cell *c, void *data) {
-
-  double *shift = (double *)data;
-
-  printf("%g\t%g\t%g\n", p->x[0] - shift[0], p->x[1] - shift[1],
-         p->x[2] - shift[2]);
-}
-
-/**
- * @brief Compute the average number of pairs per particle using
- *      a brute-force O(N^2) computation.
- *
- * @param dim The space dimensions.
- * @param parts The #part array.
- * @param N The number of parts.
- * @param periodic Periodic boundary conditions flag.
- */
-
-void pairs_n2(double *dim, struct part *__restrict__ parts, int N,
-              int periodic) {
-
-  int i, j, k, count = 0;
-  // int mj, mk;
-  // double maxratio = 1.0;
-  double r2, dx[3], rho = 0.0;
-  double rho_max = 0.0, rho_min = 100;
-
-  /* Loop over all particle pairs. */
-  for (j = 0; j < N; j++) {
-    if (j % 1000 == 0) {
-      printf("pairs_n2: j=%i.\n", j);
-      fflush(stdout);
-    }
-    for (k = j + 1; k < N; k++) {
-      for (i = 0; i < 3; i++) {
-        dx[i] = parts[j].x[i] - parts[k].x[i];
-        if (periodic) {
-          if (dx[i] < -dim[i] / 2)
-            dx[i] += dim[i];
-          else if (dx[i] > dim[i] / 2)
-            dx[i] -= dim[i];
-        }
-      }
-      r2 = dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2];
-      if (r2 < parts[j].h * parts[j].h || r2 < parts[k].h * parts[k].h) {
-        runner_iact_density(r2, NULL, parts[j].h, parts[k].h, &parts[j],
-                            &parts[k]);
-        /* if ( parts[j].h / parts[k].h > maxratio )
-            {
-            maxratio = parts[j].h / parts[k].h;
-            mj = j; mk = k;
-            }
-        else if ( parts[k].h / parts[j].h > maxratio )
-            {
-            maxratio = parts[k].h / parts[j].h;
-            mj = j; mk = k;
-            } */
-      }
-    }
-  }
-
-  /* Aggregate the results. */
-  for (k = 0; k < N; k++) {
-    // count += parts[k].icount;
-    rho += parts[k].density.wcount;
-    rho_min = fmin(parts[k].density.wcount, rho_min);
-    rho_min = fmax(parts[k].density.wcount, rho_max);
-  }
-
-  /* Dump the result. */
-  printf("pairs_n2: avg. density per part is %.3f (nr. pairs %.3f).\n",
-         rho / N + 32.0 / 3, ((double)count) / N);
-  printf("pairs_n2: densities are in [ %e , %e ].\n", rho_min / N + 32.0 / 3,
-         rho_max / N + 32.0 / 3);
-  /* printf( "pairs_n2: maximum ratio between parts %i [%e,%e,%e] and %i
-     [%e,%e,%e] is %.3f/%.3f\n" ,
-      mj , parts[mj].x[0] , parts[mj].x[1] , parts[mj].x[2] ,
-      mk , parts[mk].x[0] , parts[mk].x[1] , parts[mk].x[2] ,
-      parts[mj].h , parts[mk].h ); fflush(stdout); */
-  fflush(stdout);
-}
-
-void pairs_single_density(double *dim, long long int pid,
-                          struct part *__restrict__ parts, int N,
-                          int periodic) {
-
-  int i, k;
-  // int mj, mk;
-  // double maxratio = 1.0;
-  double r2, dx[3];
-  float fdx[3];
-  struct part p;
-  // double ih = 12.0/6.25;
-
-  /* Find "our" part. */
-  for (k = 0; k < N && parts[k].id != pid; k++)
-    ;
-  if (k == N) error("Part not found.");
-  p = parts[k];
-  printf("pairs_single: part[%i].id == %lli.\n", k, pid);
-
-  p.rho = 0.0;
-  p.density.wcount = 0.0;
-  // p.icount = 0;
-  p.rho_dh = 0.0;
-
-  /* Loop over all particle pairs. */
-  for (k = 0; k < N; k++) {
-    if (parts[k].id == p.id) continue;
-    for (i = 0; i < 3; i++) {
-      dx[i] = p.x[i] - parts[k].x[i];
-      if (periodic) {
-        if (dx[i] < -dim[i] / 2)
-          dx[i] += dim[i];
-        else if (dx[i] > dim[i] / 2)
-          dx[i] -= dim[i];
-      }
-      fdx[i] = dx[i];
-    }
-    r2 = fdx[0] * fdx[0] + fdx[1] * fdx[1] + fdx[2] * fdx[2];
-    if (r2 < p.h * p.h) {
-      runner_iact_nonsym_density(r2, fdx, p.h, parts[k].h, &p, &parts[k]);
-      /* printf( "pairs_simple: interacting particles %lli [%i,%i,%i] and %lli
-         [%i,%i,%i], r=%e.\n" ,
-          pid , (int)(p.x[0]*ih) , (int)(p.x[1]*ih) , (int)(p.x[2]*ih) ,
-          parts[k].id , (int)(parts[k].x[0]*ih) , (int)(parts[k].x[1]*ih) ,
-         (int)(parts[k].x[2]*ih) ,
-          sqrtf(r2) ); */
-    }
-  }
-
-  /* Dump the result. */
-  printf("pairs_single: wcount of part %lli (h=%e) is %f.\n", p.id, p.h,
-         p.density.wcount + 32.0 / 3);
-  fflush(stdout);
-}
-
-void pairs_single_grav(double *dim, long long int pid,
-                       struct gpart *__restrict__ parts, int N, int periodic) {
-
-  int i, k;
-  // int mj, mk;
-  // double maxratio = 1.0;
-  double r2, dx[3];
-  float fdx[3], a[3] = {0.0, 0.0, 0.0}, aabs[3] = {0.0, 0.0, 0.0};
-  struct gpart pi, pj;
-  // double ih = 12.0/6.25;
-
-  /* Find "our" part. */
-  for (k = 0; k < N; k++)
-    if ((parts[k].id > 0 && parts[k].part->id == pid) || parts[k].id == -pid)
-      break;
-  if (k == N) error("Part not found.");
-  pi = parts[k];
-  pi.a[0] = 0.0f;
-  pi.a[1] = 0.0f;
-  pi.a[2] = 0.0f;
-
-  /* Loop over all particle pairs. */
-  for (k = 0; k < N; k++) {
-    if (parts[k].id == pi.id) continue;
-    pj = parts[k];
-    for (i = 0; i < 3; i++) {
-      dx[i] = pi.x[i] - pj.x[i];
-      if (periodic) {
-        if (dx[i] < -dim[i] / 2)
-          dx[i] += dim[i];
-        else if (dx[i] > dim[i] / 2)
-          dx[i] -= dim[i];
-      }
-      fdx[i] = dx[i];
-    }
-    r2 = fdx[0] * fdx[0] + fdx[1] * fdx[1] + fdx[2] * fdx[2];
-    runner_iact_grav(r2, fdx, &pi, &pj);
-    a[0] += pi.a[0];
-    a[1] += pi.a[1];
-    a[2] += pi.a[2];
-    aabs[0] += fabsf(pi.a[0]);
-    aabs[1] += fabsf(pi.a[1]);
-    aabs[2] += fabsf(pi.a[2]);
-    pi.a[0] = 0.0f;
-    pi.a[1] = 0.0f;
-    pi.a[2] = 0.0f;
-  }
-
-  /* Dump the result. */
-  message(
-      "acceleration on gpart %lli is a=[ %e %e %e ], |a|=[ %.2e %.2e %.2e ].\n",
-      pi.part->id, a[0], a[1], a[2], aabs[0], aabs[1], aabs[2]);
-}
-
-/**
- * @brief Test the kernel function by dumping it in the interval [0,1].
- *
- * @param N number of intervals in [0,1].
- */
 
-void kernel_dump(int N) {
-
-  int k;
-  float x, w, dw_dx;
-  float x4[4] = {0.0f, 0.0f, 0.0f, 0.0f};
-  float w4[4] = {0.0f, 0.0f, 0.0f, 0.0f};
-  // float dw_dx4[4] __attribute__ ((aligned (16)));
-
-  for (k = 0; k <= N; k++) {
-    x = ((float)k) / N;
-    x4[3] = x4[2];
-    x4[2] = x4[1];
-    x4[1] = x4[0];
-    x4[0] = x;
-    kernel_deval(x, &w, &dw_dx);
-    // kernel_deval_vec( (vector *)x4 , (vector *)w4 , (vector *)dw_dx4 );
-    printf(" %e %e %e %e %e %e %e\n", x, w, dw_dx, w4[0], w4[1], w4[2], w4[3]);
-  }
-}
-
-float gadget(float r) {
-  float fac, h_inv, u, r2 = r * r;
-  if (r >= const_epsilon)
-    fac = 1.0f / (r2 * r);
-  else {
-    h_inv = 1. / const_epsilon;
-    u = r * h_inv;
-    if (u < 0.5)
-      fac = const_iepsilon3 * (10.666666666667 + u * u * (32.0 * u - 38.4));
-    else
-      fac = const_iepsilon3 *
-            (21.333333333333 - 48.0 * u + 38.4 * u * u -
-             10.666666666667 * u * u * u - 0.066666666667 / (u * u * u));
-  }
-  return const_G * fac;
-}
 
-void gravity_dump(float r_max, int N) {
-
-  int k;
-  float x, w;
-  float x4[4] = {0.0f, 0.0f, 0.0f, 0.0f};
-  float w4[4] = {0.0f, 0.0f, 0.0f, 0.0f};
-  // float dw_dx4[4] __attribute__ ((aligned (16)));
-
-  for (k = 1; k <= N; k++) {
-    x = (r_max * k) / N;
-    x4[3] = x4[2];
-    x4[2] = x4[1];
-    x4[1] = x4[0];
-    x4[0] = x;
-    kernel_grav_eval(x, &w);
-    w *= const_G / (x * x * x);
-    // blender_deval_vec( (vector *)x4 , (vector *)w4 , (vector *)dw_dx4 );
-    printf(" %.16e %.16e %.16e %.16e %.16e %.16e %.16e\n", x, w * x, w4[0],
-           w4[1], w4[2], w4[3], gadget(x) * x);
-  }
-}
-
-/**
- * @brief Test the density function by dumping it for two random parts.
- *
- * @param N number of intervals in [0,1].
- */
-
-void density_dump(int N) {
-
-  int k;
-  float r2[4] = {0.0f, 0.0f, 0.0f, 0.0f}, hi[4], hj[4];
-  struct part *pi[4], *pj[4], Pi[4], Pj[4];
-
-  /* Init the interaction parameters. */
-  for (k = 0; k < 4; k++) {
-    Pi[k].mass = 1.0f;
-    Pi[k].rho = 0.0f;
-    Pi[k].density.wcount = 0.0f;
-    Pj[k].mass = 1.0f;
-    Pj[k].rho = 0.0f;
-    Pj[k].density.wcount = 0.0f;
-    hi[k] = 1.0;
-    hj[k] = 1.0;
-    pi[k] = &Pi[k];
-    pj[k] = &Pj[k];
-  }
-
-  for (k = 0; k <= N; k++) {
-    r2[3] = r2[2];
-    r2[2] = r2[1];
-    r2[1] = r2[0];
-    r2[0] = ((float)k) / N;
-    Pi[0].density.wcount = 0;
-    Pj[0].density.wcount = 0;
-    runner_iact_density(r2[0], NULL, hi[0], hj[0], &Pi[0], &Pj[0]);
-    printf(" %e %e %e", r2[0], Pi[0].density.wcount, Pj[0].density.wcount);
-    Pi[0].density.wcount = 0;
-    Pj[0].density.wcount = 0;
-    Pi[1].density.wcount = 0;
-    Pj[1].density.wcount = 0;
-    Pi[2].density.wcount = 0;
-    Pj[2].density.wcount = 0;
-    Pi[3].density.wcount = 0;
-    Pj[3].density.wcount = 0;
-    runner_iact_vec_density(r2, NULL, hi, hj, pi, pj);
-    printf(" %e %e %e %e\n", Pi[0].density.wcount, Pi[1].density.wcount,
-           Pi[2].density.wcount, Pi[3].density.wcount);
-  }
-}
-
-/**
- *  Factorize a given integer, attempts to keep larger pair of factors.
- */
-void factor(int value, int *f1, int *f2) {
-  int j;
-  int i;
-
-  j = (int)sqrt(value);
-  for (i = j; i > 0; i--) {
-    if ((value % i) == 0) {
-      *f1 = i;
-      *f2 = value / i;
-      break;
-    }
-  }
-}
 
 /**
  * @brief Main routine that loads a few particles and generates some output.
@@ -576,14 +91,12 @@ int main(int argc, char *argv[]) {
 #ifdef WITH_MPI
   /* Start by initializing MPI. */
   int res, prov;
-  if ((res = MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &prov)) !=
-      MPI_SUCCESS)
+  if ((res = MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &prov)) != MPI_SUCCESS)
     error("Call to MPI_Init failed with error %i.", res);
   if (prov != MPI_THREAD_MULTIPLE)
-    error(
-        "MPI does not provide the level of threading required "
-        "(MPI_THREAD_MULTIPLE).");
-  if ((res = MPI_Comm_size(MPI_COMM_WORLD, &nr_nodes) != MPI_SUCCESS))
+    error("MPI does not provide the level of threading required "
+          "(MPI_THREAD_MULTIPLE).");
+  if ((res = MPI_Comm_size(MPI_COMM_WORLD, &nr_nodes)) != MPI_SUCCESS)
     error("MPI_Comm_size failed with error %i.", res);
   if ((res = MPI_Comm_rank(MPI_COMM_WORLD, &myrank)) != MPI_SUCCESS)
     error("Call to MPI_Comm_rank failed with error %i.", res);
@@ -639,7 +152,7 @@ int main(int argc, char *argv[]) {
         break;
       case 'o':
         with_outputs = 0;
-	break;
+        break;
       case 'q':
         if (sscanf(optarg, "%d", &nr_queues) != 1)
           error("Error parsing number of queues.");
@@ -678,17 +191,20 @@ int main(int argc, char *argv[]) {
     }
 
 #if defined(WITH_MPI)
-  if (myrank == 0) message("Running with %i thread(s) per node.", nr_threads);
+  if (myrank == 0) {
+    message("Running with %i thread(s) per node.", nr_threads);
+    message("grid set to [ %i %i %i ].", grid[0], grid[1], grid[2]);
+
+    if (nr_nodes == 1) {
+      message("WARNING: you are running with one MPI rank.");
+      message("WARNING: you should use the non-MPI version of this program." );
+    }
+    fflush(stdout);
+  }
 #else
   if (myrank == 0) message("Running with %i thread(s).", nr_threads);
 #endif
 
-#if defined(WITH_MPI)
-  if (myrank == 0)
-    message("grid set to [ %i %i %i ].", grid[0], grid[1], grid[2]);
-  fflush(stdout);
-#endif
-
   /* How large are the parts? */
   if (myrank == 0) {
     message("sizeof(struct part) is %li bytes.", (long int)sizeof(struct part));
@@ -696,7 +212,7 @@ int main(int argc, char *argv[]) {
             (long int)sizeof(struct gpart));
   }
 
-  /* Initilaize unit system */
+  /* Initialize unit system */
   initUnitSystem(&us);
   if (myrank == 0) {
     message("Unit system: U_M = %e g.", us.UnitMass_in_cgs);
@@ -781,7 +297,7 @@ int main(int argc, char *argv[]) {
     // message( "cutoffs in [ %g %g ]." , s.h_min , s.h_max ); fflush(stdout);
   }
 
-  /* Verify that each particle is in it's propper cell. */
+  /* Verify that each particle is in it's proper cell. */
   if (myrank == 0) {
     icount = 0;
     space_map_cells_pre(&s, 0, &map_cellcheck, &icount);
@@ -890,7 +406,7 @@ int main(int argc, char *argv[]) {
 #endif
     }
 
-    /* Dump a line of agregate output. */
+    /* Dump a line of aggregate output. */
     /*     if (myrank == 0) { */
     /*       printf("%i %e %.16e %.16e %.16e %.3e %.3e %i %.3e %.3e", j, e.time,
      */
diff --git a/examples/plot_tasks.py b/examples/plot_tasks.py
index 3e01be7da31ff87ba137cae394a203d5a6de7b25..52f1a90592120e61bd3e789ee0cb8fe7edb63a8d 100644
--- a/examples/plot_tasks.py
+++ b/examples/plot_tasks.py
@@ -1,6 +1,6 @@
 ###############################################################################
  # This file is part of SWIFT.
- # Coypright (c) 2015 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+ # Copyright (c) 2015 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
  #                    Bert Vandenbroucke (bert.vandenbroucke@ugent.be)
  #                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
  # 
diff --git a/examples/runs.sh b/examples/runs.sh
index ff8e3339d69bd414c9c55b4ed60d532db121d55c..e31dc5a090eb512f9e5ae3b301610cd51839d9bb 100755
--- a/examples/runs.sh
+++ b/examples/runs.sh
@@ -34,31 +34,31 @@ do
     # Sod-Shock runs
     if [ ! -e SodShock_mindt_${cpu}.dump ]
     then
-        ./test_mindt -c 1.0 -t $cpu -f SodShock/sodShock.hdf5 -m 0.01 -w 5000 -d 1.0 > SodShock_${cpu}.dump
+        ./swift_mindt -c 1.0 -t $cpu -f SodShock/sodShock.hdf5 -m 0.01 -w 5000 -d 1.0 > SodShock_${cpu}.dump
     fi
     if [ ! -e SodShock_fixed_${cpu}.dump ]
     then
-        ./test_fixdt -r 1000 -t $cpu -f SodShock/sodShock.hdf5 -m 0.01 -w 5000 -d 1e-4 > SodShock_fixed_${cpu}.dump
+        ./swift_fixdt -r 1000 -t $cpu -f SodShock/sodShock.hdf5 -m 0.01 -w 5000 -d 1e-4 > SodShock_fixed_${cpu}.dump
     fi
     
     # Sedov blast
     if [ ! -e SedovBlast_mindt_${cpu}.dump ]
     then
-        ./test_mindt -c 0.2 -t $cpu -f SedovBlast/sedov.hdf5 -m 0.02 -w 5000 -d 1e-10 > SedovBlast_${cpu}.dump
+        ./swift_mindt -c 0.2 -t $cpu -f SedovBlast/sedov.hdf5 -m 0.02 -w 5000 -d 1e-10 > SedovBlast_${cpu}.dump
     fi
     if [ ! -e SedovBlast_fixed_${cpu}.dump ]
     then
-        ./test_fixdt -r 4096 -t $cpu -f SedovBlast/sedov.hdf5 -m 0.02 -w 5000 -d 5e-5 > SedovBlast_fixed_${cpu}.dump
+        ./swift_fixdt -r 4096 -t $cpu -f SedovBlast/sedov.hdf5 -m 0.02 -w 5000 -d 5e-5 > SedovBlast_fixed_${cpu}.dump
     fi
     
     # Cosmological volume
     if [ ! -e CosmoVolume_mindt_${cpu}.dump ]
     then
-        ./test_mindt -c 0.01 -t $cpu -f CosmoVolume/cosmoVolume.hdf5 -m 0.6 -w 5000 -d 0.01 > CosmoVolume_${cpu}.dump
+        ./swift_mindt -c 0.01 -t $cpu -f CosmoVolume/cosmoVolume.hdf5 -m 0.6 -w 5000 -d 0.01 > CosmoVolume_${cpu}.dump
     fi
     if [ ! -e CosmoVolume_fixed_${cpu}.dump ]
     then
-        ./test_fixdt -r 256 -t $cpu -f CosmoVolume/cosmoVolume.hdf5 -m 0.6 -w 5000 -d 1e-8 > CosmoVolume_fixed_${cpu}.dump
+        ./swift_fixdt -r 256 -t $cpu -f CosmoVolume/cosmoVolume.hdf5 -m 0.6 -w 5000 -d 1e-8 > CosmoVolume_fixed_${cpu}.dump
     fi
 
 done
diff --git a/examples/runs_mpi_cv.sh b/examples/runs_mpi_cv.sh
index 4a009bbdbeb18d003b7572cc1dcb7b7e3fa19a2c..bffa2d56a6a8f3624c0919db8a046dd2db0b80b4 100755
--- a/examples/runs_mpi_cv.sh
+++ b/examples/runs_mpi_cv.sh
@@ -23,43 +23,43 @@ for cpu in $(seq 1 $CPN)
 do
     if [ ! -e ${PREFIX}_${QUEUE}_1x${cpu}.dump ]
     then
-        bsub -oo ${PREFIX}_${QUEUE}_1x${cpu}.dump -q ${QUEUE} -P ${PROJECT} -x -n 1 -R "span[ptile=1]" ./test_fixdt -r $RUNS -t $cpu -f ${INPUT} -m 0.705 -w 6000 -z 300 -d 1e-8
+        bsub -oo ${PREFIX}_${QUEUE}_1x${cpu}.dump -q ${QUEUE} -P ${PROJECT} -x -n 1 -R "span[ptile=1]" ./swift_fixdt -r $RUNS -t $cpu -f ${INPUT} -m 0.705 -w 6000 -z 300 -d 1e-8
     fi
 done
 
 # Multi-node runs
 if [ ! -e ${PREFIX}_${QUEUE}_2x${cpu}.dump ]
 then
-    bsub -oo ${PREFIX}_${QUEUE}_2x${CPN}.dump -q ${QUEUE} -P ${PROJECT} -x -W 02:00 -n 2 -R "span[ptile=1]" mpirun -np 2 ./test_fixdt_mpi -r $RUNS -t $CPN -g "2 1 1" -f ${INPUT} -m 0.705 -w 6000 -z 300 -d 1e-8
+    bsub -oo ${PREFIX}_${QUEUE}_2x${CPN}.dump -q ${QUEUE} -P ${PROJECT} -x -W 02:00 -n 2 -R "span[ptile=1]" mpirun -np 2 ./swift_fixdt_mpi -r $RUNS -t $CPN -g "2 1 1" -f ${INPUT} -m 0.705 -w 6000 -z 300 -d 1e-8
 fi
 
 if [ ! -e ${PREFIX}_${QUEUE}_4x${cpu}.dump ]
 then
-    bsub -oo ${PREFIX}_${QUEUE}_4x${CPN}.dump -q ${QUEUE} -P ${PROJECT} -x -W 02:00 -n 4 -R "span[ptile=1]" mpirun -np 4 ./test_fixdt_mpi -r $RUNS -t $CPN -g "2 2 1" -f ${INPUT} -m 0.705 -w 6000 -z 300 -d 1e-8
+    bsub -oo ${PREFIX}_${QUEUE}_4x${CPN}.dump -q ${QUEUE} -P ${PROJECT} -x -W 02:00 -n 4 -R "span[ptile=1]" mpirun -np 4 ./swift_fixdt_mpi -r $RUNS -t $CPN -g "2 2 1" -f ${INPUT} -m 0.705 -w 6000 -z 300 -d 1e-8
 fi
 
 if [ ! -e ${PREFIX}_${QUEUE}_8x${cpu}.dump ]
 then
-    bsub -oo ${PREFIX}_${QUEUE}_8x${CPN}.dump -q ${QUEUE} -P ${PROJECT} -x -W 02:00 -n 8 -R "span[ptile=1]" mpirun -np 8 ./test_fixdt_mpi -r $RUNS -t $CPN -g "2 2 2" -f ${INPUT} -m 0.705 -w 6000 -z 300 -d 1e-8
+    bsub -oo ${PREFIX}_${QUEUE}_8x${CPN}.dump -q ${QUEUE} -P ${PROJECT} -x -W 02:00 -n 8 -R "span[ptile=1]" mpirun -np 8 ./swift_fixdt_mpi -r $RUNS -t $CPN -g "2 2 2" -f ${INPUT} -m 0.705 -w 6000 -z 300 -d 1e-8
 fi
 
 if [ ! -e ${PREFIX}_${QUEUE}_16x${cpu}.dump ]
 then
-    bsub -oo ${PREFIX}_${QUEUE}_16x${CPN}.dump -q ${QUEUE} -P ${PROJECT} -x -W 02:00 -n 16 -R "span[ptile=1]" mpirun -np 16 ./test_fixdt_mpi -r $RUNS -t $CPN -g "4 2 2" -f ${INPUT} -m 0.705 -w 6000 -z 300 -d 1e-8
+    bsub -oo ${PREFIX}_${QUEUE}_16x${CPN}.dump -q ${QUEUE} -P ${PROJECT} -x -W 02:00 -n 16 -R "span[ptile=1]" mpirun -np 16 ./swift_fixdt_mpi -r $RUNS -t $CPN -g "4 2 2" -f ${INPUT} -m 0.705 -w 6000 -z 300 -d 1e-8
 fi
 
 if [ ! -e ${PREFIX}_${QUEUE}_32x${cpu}.dump ]
 then
-    bsub -oo ${PREFIX}_${QUEUE}_32x${CPN}.dump -q ${QUEUE} -P ${PROJECT} -x -W 02:00 -n 32 -R "span[ptile=1]" mpirun -np 32 ./test_fixdt_mpi -r $RUNS -t $CPN -g "4 4 2" -f ${INPUT} -m 0.705 -w 6000 -z 300 -d 1e-8
+    bsub -oo ${PREFIX}_${QUEUE}_32x${CPN}.dump -q ${QUEUE} -P ${PROJECT} -x -W 02:00 -n 32 -R "span[ptile=1]" mpirun -np 32 ./swift_fixdt_mpi -r $RUNS -t $CPN -g "4 4 2" -f ${INPUT} -m 0.705 -w 6000 -z 300 -d 1e-8
 fi
 
 if [ ! -e ${PREFIX}_${QUEUE}_64x${cpu}.dump ]
 then
-    bsub -oo ${PREFIX}_${QUEUE}_64x${CPN}.dump -q ${QUEUE} -P ${PROJECT} -x -W 02:00 -n 64 -R "span[ptile=1]" mpirun -np 64 ./test_fixdt_mpi -r $RUNS -t $CPN -g "4 4 4" -f ${INPUT} -m 0.705 -w 6000 -z 300 -d 1e-8
+    bsub -oo ${PREFIX}_${QUEUE}_64x${CPN}.dump -q ${QUEUE} -P ${PROJECT} -x -W 02:00 -n 64 -R "span[ptile=1]" mpirun -np 64 ./swift_fixdt_mpi -r $RUNS -t $CPN -g "4 4 4" -f ${INPUT} -m 0.705 -w 6000 -z 300 -d 1e-8
 fi
 
 if [ ! -e ${PREFIX}_${QUEUE}_128x${cpu}.dump ]
 then
-    bsub -oo ${PREFIX}_${QUEUE}_128x${CPN}.dump -q ${QUEUE} -P ${PROJECT} -x -W 02:00 -n 128 -R "span[ptile=1]" mpirun -np 128 ./test_fixdt_mpi -r $RUNS -t $CPN -g "8 4 4" -f ${INPUT} -m 0.705 -w 6000 -z 300 -d 1e-8
+    bsub -oo ${PREFIX}_${QUEUE}_128x${CPN}.dump -q ${QUEUE} -P ${PROJECT} -x -W 02:00 -n 128 -R "span[ptile=1]" mpirun -np 128 ./swift_fixdt_mpi -r $RUNS -t $CPN -g "8 4 4" -f ${INPUT} -m 0.705 -w 6000 -z 300 -d 1e-8
 fi
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 46841c6394f5c6c024f1428a06d1025fa6604962..0fdc51571424e2a9ad91d1d7c714d91446702161 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,6 +1,6 @@
 
 # This file is part of SWIFT.
-# Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+# Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
 #                    Matthieu Schaller (matthieu.schaller@durham.ac.uk).
 #
 # This program is free software: you can redistribute it and/or modify
@@ -35,12 +35,13 @@ endif
 # List required headers
 include_HEADERS = space.h runner.h queue.h task.h lock.h cell.h part.h const.h \
     engine.h swift.h serial_io.h timers.h debug.h scheduler.h proxy.h parallel_io.h \
-    common_io.h single_io.h multipole.h
+    common_io.h single_io.h multipole.h map.h tools.h
 
 # Common source files
 AM_SOURCES = space.c runner.c queue.c task.c cell.c engine.c \
     serial_io.c timers.c debug.c scheduler.c proxy.c parallel_io.c \
-    units.c common_io.c single_io.c multipole.c version.c
+    units.c common_io.c single_io.c multipole.c version.c map.c \
+    kernel.c tools.c
 
 # Include files for distribution, not installation.
 noinst_HEADERS = atomic.h cycle.h error.h inline.h kernel.h vector.h \
diff --git a/src/atomic.h b/src/atomic.h
index 16b268c4c799cd1ca8c38a3382df912a9d618614..818d210e60a7aacdf61d12b60623ce87e62c9ed2 100644
--- a/src/atomic.h
+++ b/src/atomic.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
diff --git a/src/cell.c b/src/cell.c
index 87b51ac82cade8a7e4302e52b7a4e55e5d612aa2..a1653ae0d0b88cc1f09a8dc55daff2929453a58e 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
@@ -299,7 +299,7 @@ int cell_glocktree(struct cell *c) {
 }
 
 /**
- * @brief Unock a cell's parents.
+ * @brief Unlock a cell's parents.
  *
  * @param c The #cell.
  */
diff --git a/src/cell.h b/src/cell.h
index 7a5353bcae8cbb7ab4d50a546665a1a774a46aea..d5d8b5db8ba3005eb3bdeaee5789fe8d7e39480f 100644
--- a/src/cell.h
+++ b/src/cell.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
diff --git a/src/common_io.c b/src/common_io.c
index a09f9c9ac37d280a4ae2838b3b7e36556e81047a..6ed22a582016f2bd6506a193a75c21988e1c5553 100644
--- a/src/common_io.c
+++ b/src/common_io.c
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
  *                    Matthieu Schaller (matthieu.schaller@durham.ac.uk).
  *
  * This program is free software: you can redistribute it and/or modify
@@ -218,7 +218,7 @@ void writeStringAttribute(hid_t grp, char* name, const char* str, int length) {
 
 /**
  * @brief Writes a double value as an attribute
- * @param grp The groupm in which to write
+ * @param grp The group in which to write
  * @param name The name of the attribute
  * @param data The value to write
  */
@@ -228,7 +228,7 @@ void writeAttribute_d(hid_t grp, char* name, double data) {
 
 /**
  * @brief Writes a float value as an attribute
- * @param grp The groupm in which to write
+ * @param grp The group in which to write
  * @param name The name of the attribute
  * @param data The value to write
  */
@@ -238,7 +238,7 @@ void writeAttribute_f(hid_t grp, char* name, float data) {
 
 /**
  * @brief Writes an int value as an attribute
- * @param grp The groupm in which to write
+ * @param grp The group in which to write
  * @param name The name of the attribute
  * @param data The value to write
  */
@@ -249,7 +249,7 @@ void writeAttribute_i(hid_t grp, char* name, int data) {
 
 /**
  * @brief Writes a long value as an attribute
- * @param grp The groupm in which to write
+ * @param grp The group in which to write
  * @param name The name of the attribute
  * @param data The value to write
  */
@@ -259,7 +259,7 @@ void writeAttribute_l(hid_t grp, char* name, long data) {
 
 /**
  * @brief Writes a string value as an attribute
- * @param grp The groupm in which to write
+ * @param grp The group in which to write
  * @param name The name of the attribute
  * @param str The string to write
  */
diff --git a/src/common_io.h b/src/common_io.h
index c58ffae4d76dafe71faf44395f7f280120f4f0fe..c221ad3aaf84deb83c0067ee4ece729b98003430 100644
--- a/src/common_io.h
+++ b/src/common_io.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
  *                    Matthieu Schaller (matthieu.schaller@durham.ac.uk).
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/src/const.h b/src/const.h
index ccccf6fa89884328efb33fcb018e0b17228fceff..d62673332c2d19872cad1d9c62ca6eff7f0e013a 100644
--- a/src/const.h
+++ b/src/const.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (ptcedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2012 Pedro Gonnet (ptcedro.gonnet@durham.ac.uk)
  *                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/src/debug.c b/src/debug.c
index d55d5443457fe3be41f6d1983a1eca8d7ab99f3c..f245e881d718c27c075a6ae13d62a49d43b5f7e9 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2013 Matthieu Schaller (matthieu.schaller@durham.ac.uk),
+ * Copyright (c) 2013 Matthieu Schaller (matthieu.schaller@durham.ac.uk),
  *                    Pedro Gonnet (pedro.gonnet@durham.ac.uk).
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/src/debug.h b/src/debug.h
index 5c9eb7b32db8ef5d07d97b867c68ec09b848e337..83461df45e3c0fb137557fba5fdf68cac9d4915a 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Matthieu Schaller (matthieu.schaller@durham.ac.uk).
+ * Copyright (c) 2012 Matthieu Schaller (matthieu.schaller@durham.ac.uk).
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
diff --git a/src/engine.c b/src/engine.c
index 4e73118dea7f6a4ec8f98a24001c292fa4d61fff..70bd5e31c61c38028a4e8f773fe722f61840700e 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
@@ -127,7 +127,7 @@ void engine_mkghosts(struct engine *e, struct cell *c, struct cell *super) {
 }
 
 /**
- * @brief Redistribute the particles amongst the nodes accorind
+ * @brief Redistribute the particles amongst the nodes according
  *      to their cell's node IDs.
  *
  * @param e The #engine.
@@ -280,7 +280,7 @@ void engine_redistribute(struct engine *e) {
   free(dest);
 
 #else
-  error("SWIFT was not compiled with MPI and METIS support.");
+  error("SWIFT was not compiled with MPI support.");
 #endif
 }
 
@@ -311,6 +311,10 @@ void engine_repartition(struct engine *e) {
   /* Clear the repartition flag. */
   e->forcerepart = 0;
 
+  /* Nothing to do if only using a single node. Also avoids METIS
+   * bug that doesn't handle this case well. */
+  if ( nr_nodes == 1 ) return;
+
   /* Allocate the inds and weights. */
   if ((inds = (idx_t *)malloc(sizeof(idx_t) * 26 *nr_cells)) == NULL ||
       (weights_v = (idx_t *)malloc(sizeof(idx_t) *nr_cells)) == NULL ||
@@ -457,7 +461,7 @@ void engine_repartition(struct engine *e) {
     for (k = 0; k < nr_cells; k++) weights_v[k] *= scale;
   }
 
-/* Merge the weights arrays accross all nodes. */
+/* Merge the weights arrays across all nodes. */
 #if IDXTYPEWIDTH == 32
   if ((res = MPI_Reduce((nodeID == 0) ? MPI_IN_PLACE : weights_v, weights_v,
                         nr_cells, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD)) !=
@@ -585,7 +589,7 @@ void engine_repartition(struct engine *e) {
   /* Now comes the tricky part: Exchange particles between all nodes.
      This is done in two steps, first allreducing a matrix of
      how many particles go from where to where, then re-allocating
-     the parts array, and emiting the sends and receives.
+     the parts array, and emitting the sends and receives.
      Finally, the space, tasks, and proxies need to be rebuilt. */
 
   /* Redistribute the particles between the nodes. */
@@ -773,7 +777,7 @@ void engine_exchange_cells(struct engine *e) {
     proxy_cells_exch2(&e->proxies[pid]);
   }
 
-  /* Wait for all the sends to have finnished too. */
+  /* Wait for all the sends to have finished too. */
   if (MPI_Waitall(nr_proxies, reqs_out, MPI_STATUSES_IGNORE) != MPI_SUCCESS)
     error("MPI_Waitall on sends failed.");
 
@@ -794,7 +798,7 @@ void engine_exchange_cells(struct engine *e) {
                            e->proxies[pid].cells_in[j], e->s);
   }
 
-  /* Wait for all the sends to have finnished too. */
+  /* Wait for all the sends to have finished too. */
   if (MPI_Waitall(nr_proxies, reqs_out, MPI_STATUSES_IGNORE) != MPI_SUCCESS)
     error("MPI_Waitall on sends failed.");
 
@@ -891,11 +895,11 @@ int engine_exchange_strays(struct engine *e, int offset, int *ind, int N) {
     proxy_parts_exch2(&e->proxies[pid]);
   }
 
-  /* Wait for all the sends to have finnished too. */
+  /* Wait for all the sends to have finished too. */
   if (MPI_Waitall(e->nr_proxies, reqs_out, MPI_STATUSES_IGNORE) != MPI_SUCCESS)
     error("MPI_Waitall on sends failed.");
 
-  /* Count the total number of incomming particles and make sure we have
+  /* Count the total number of incoming particles and make sure we have
      enough space to accommodate them. */
   int count_in = 0;
   for (k = 0; k < e->nr_proxies; k++) count_in += e->proxies[k].nr_parts_in;
@@ -962,7 +966,7 @@ int engine_exchange_strays(struct engine *e, int offset, int *ind, int N) {
     }
   }
 
-  /* Wait for all the sends to have finnished too. */
+  /* Wait for all the sends to have finished too. */
   if (nr_out > 0)
     if (MPI_Waitall(2 * e->nr_proxies, reqs_out, MPI_STATUSES_IGNORE) !=
         MPI_SUCCESS)
@@ -1220,7 +1224,7 @@ void engine_maketasks(struct engine *e) {
     /* Get a handle on the proxy. */
     struct proxy *p = &e->proxies[pid];
 
-    /* Loop through the proxy's incomming cells and add the
+    /* Loop through the proxy's incoming cells and add the
        recv tasks. */
     for (k = 0; k < p->nr_cells_in; k++)
       engine_addtasks_recv(e, p->cells_in[k], NULL, NULL);
@@ -1453,7 +1457,7 @@ void engine_prepare(struct engine *e) {
   int buff;
   if (MPI_Allreduce(&rebuild, &buff, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD) !=
       MPI_SUCCESS)
-    error("Failed to aggreggate the rebuild flag accross nodes.");
+    error("Failed to aggregate the rebuild flag across nodes.");
   rebuild = buff;
 // message( "rebuild allreduce took %.3f ms." , (double)(getticks() -
 // tic)/CPU_TPS*1000 );
@@ -1504,7 +1508,7 @@ void engine_barrier(struct engine *e, int tid) {
   /* Wait for the barrier to open. */
   while (e->barrier_launch == 0 || tid >= e->barrier_launchcount)
     if (pthread_cond_wait(&e->barrier_cond, &e->barrier_mutex) != 0)
-      error("Eror waiting for barrier to close.");
+      error("Error waiting for barrier to close.");
 
   /* This thread has been launched. */
   e->barrier_running += 1;
@@ -2075,7 +2079,7 @@ void engine_split(struct engine *e, int *grid) {
  * @param nr_queues The number of task queues to create.
  * @param nr_nodes The number of MPI ranks
  * @param nodeID The MPI rank of this node
- * @param policy The queueing policy to use.
+ * @param policy The queuing policy to use.
  */
 
 void engine_init(struct engine *e, struct space *s, float dt, int nr_threads,
diff --git a/src/engine.h b/src/engine.h
index dcf0d5cc0912aca42782d09df01fae6edfa45d81..c450532909557f2374ec76af6b58050fd9483bb9 100644
--- a/src/engine.h
+++ b/src/engine.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
diff --git a/src/error.h b/src/error.h
index 6dd6b2a93936b2821071cc96cce4bdd127b2e9ae..e478e4bfc9714bea30732f7542539752517e5fa2 100644
--- a/src/error.h
+++ b/src/error.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
  *                    Matthieu Schaller (matthieu.schaller@durham.ac.uk).
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/src/inline.h b/src/inline.h
index 06728cb87f5e342b22d4a4a861cbd83ea6af31d9..c4dd9d59becabf54895b60cf3ac7ba809ac150c5 100644
--- a/src/inline.h
+++ b/src/inline.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
  *                    Matthieu Schaller (matthieu.schaller@durham.ac.uk).
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/src/intrinsics.h b/src/intrinsics.h
index 4bb97e351f0a1e6dafe1c686e90f5038d98e7217..21b8c8e68bc45d8799db496ff30ac0cfb289acea 100644
--- a/src/intrinsics.h
+++ b/src/intrinsics.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2015 Matthieu Schaller matthieu.schaller@durham.ac.uk)
+ * Copyright (c) 2015 Matthieu Schaller matthieu.schaller@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
@@ -24,7 +24,7 @@
  * significant bit position. If x is 0, the result is undefined.
  *
  * This is a wrapper for the GCC intrinsics with an implementation (from
- * Hacker's Delight) if the compiler intrisincs are not available.
+ * Hacker's Delight) if the compiler intrinsics are not available.
  */
 __attribute__((always_inline))
     INLINE static int intrinsics_clz(unsigned int x) {
@@ -64,7 +64,7 @@ __attribute__((always_inline))
  * @brief Returns the number of 1-bits in x.
  *
  * This is a wrapper for the GCC intrinsics with an implementation (from
- * Hacker's Delight) if the compiler intrisincs are not available.
+ * Hacker's Delight) if the compiler intrinsics are not available.
  */
 __attribute__((always_inline))
     INLINE static int intrinsics_popcount(unsigned int x) {
diff --git a/src/kernel.c b/src/kernel.c
new file mode 100644
index 0000000000000000000000000000000000000000..58f5b0c9fdaa62663c65d5af18afe0a15a813834
--- /dev/null
+++ b/src/kernel.c
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * This file is part of SWIFT.
+ * Copyright (c) 2015 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+ *                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ ******************************************************************************/
+
+#include <math.h>
+#include <stdio.h>
+
+#include "kernel.h"
+
+/**
+ * @brief Test the SPH kernel function by dumping it in the interval [0,1].
+ *
+ * @param N number of intervals in [0,1].
+ */
+void SPH_kernel_dump(int N) {
+
+  int k;
+  float x, w, dw_dx;
+  float x4[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+  float w4[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+  // float dw_dx4[4] __attribute__ ((aligned (16)));
+
+  for (k = 0; k <= N; k++) {
+    x = ((float)k) / N;
+    x4[3] = x4[2];
+    x4[2] = x4[1];
+    x4[1] = x4[0];
+    x4[0] = x;
+    kernel_deval(x, &w, &dw_dx);
+    // kernel_deval_vec( (vector *)x4 , (vector *)w4 , (vector *)dw_dx4 );
+    printf(" %e %e %e %e %e %e %e\n", x, w, dw_dx, w4[0], w4[1], w4[2], w4[3]);
+  }
+}
+
+/**
+ * @brief The Gadget-2 gravity kernel function
+ *
+ * @param r The distance between particles
+ */
+float gadget(float r) {
+  float fac, h_inv, u, r2 = r * r;
+  if (r >= const_epsilon)
+    fac = 1.0f / (r2 * r);
+  else {
+    h_inv = 1. / const_epsilon;
+    u = r * h_inv;
+    if (u < 0.5)
+      fac = const_iepsilon3 * (10.666666666667 + u * u * (32.0 * u - 38.4));
+    else
+      fac = const_iepsilon3 *
+            (21.333333333333 - 48.0 * u + 38.4 * u * u -
+             10.666666666667 * u * u * u - 0.066666666667 / (u * u * u));
+  }
+  return const_G * fac;
+}
+
+/**
+ * @brief Test the gravity kernel function by dumping it in the interval [0,1].
+ *
+ * @param r_max The radius up to which the kernel is dumped.
+ * @param N number of intervals in [0,1].
+ */
+void gravity_kernel_dump(float r_max, int N) {
+
+  int k;
+  float x, w;
+  float x4[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+  float w4[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+  // float dw_dx4[4] __attribute__ ((aligned (16)));
+
+  for (k = 1; k <= N; k++) {
+    x = (r_max * k) / N;
+    x4[3] = x4[2];
+    x4[2] = x4[1];
+    x4[1] = x4[0];
+    x4[0] = x;
+    kernel_grav_eval(x, &w);
+    w *= const_G / (x * x * x);
+    // blender_deval_vec( (vector *)x4 , (vector *)w4 , (vector *)dw_dx4 );
+    printf(" %.16e %.16e %.16e %.16e %.16e %.16e %.16e\n", x, w * x, w4[0],
+           w4[1], w4[2], w4[3], gadget(x) * x);
+  }
+}
diff --git a/src/kernel.h b/src/kernel.h
index 0fc232597e1e9917d17f068407acc85b37659d42..d55e073479d1585f3677389939fa8e7c53dbe1c9 100644
--- a/src/kernel.h
+++ b/src/kernel.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
@@ -609,4 +609,8 @@ __attribute__((always_inline)) INLINE static void kernel_eval(float x,
 
 #endif  // Kernel choice
 
+/* Some cross-check functions */
+void SPH_kernel_dump(int N);
+void gravity_kernel_dump(float r_max, int N);
+
 #endif  // SWIFT_KERNEL_H
diff --git a/src/lock.h b/src/lock.h
index 19a4e74bf82d3b6bb8e305388ca42929cc9d719e..90e9f90602c120ddd10f4cdefb9b08cedbf45e0f 100644
--- a/src/lock.h
+++ b/src/lock.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
diff --git a/src/map.c b/src/map.c
new file mode 100644
index 0000000000000000000000000000000000000000..dcaa53465767d414cc54fe05940069ae5ff06d77
--- /dev/null
+++ b/src/map.c
@@ -0,0 +1,198 @@
+/*******************************************************************************
+ * This file is part of SWIFT.
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+ *                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ ******************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "error.h"
+#include "map.h"
+
+/**
+ * @brief Mapping function to draw a specific cell (gnuplot).
+ */
+
+void map_cells_plot(struct cell *c, void *data) {
+
+  int depth = *(int *)data;
+  double *l = c->loc, *h = c->h;
+
+  if (c->depth <= depth) {
+
+    printf("%.16e %.16e %.16e\n", l[0], l[1], l[2]);
+    printf("%.16e %.16e %.16e\n", l[0] + h[0], l[1], l[2]);
+    printf("%.16e %.16e %.16e\n", l[0] + h[0], l[1] + h[1], l[2]);
+    printf("%.16e %.16e %.16e\n\n\n", l[0], l[1] + h[1], l[2]);
+
+    printf("%.16e %.16e %.16e\n", l[0], l[1], l[2] + h[2]);
+    printf("%.16e %.16e %.16e\n", l[0] + h[0], l[1], l[2] + h[2]);
+    printf("%.16e %.16e %.16e\n", l[0] + h[0], l[1] + h[1], l[2] + h[2]);
+    printf("%.16e %.16e %.16e\n\n\n", l[0], l[1] + h[1], l[2] + h[2]);
+
+    printf("%.16e %.16e %.16e\n", l[0], l[1], l[2]);
+    printf("%.16e %.16e %.16e\n", l[0], l[1] + h[1], l[2]);
+    printf("%.16e %.16e %.16e\n", l[0], l[1] + h[1], l[2] + h[2]);
+    printf("%.16e %.16e %.16e\n\n\n", l[0], l[1], l[2] + h[2]);
+
+    printf("%.16e %.16e %.16e\n", l[0] + h[0], l[1], l[2]);
+    printf("%.16e %.16e %.16e\n", l[0] + h[0], l[1] + h[1], l[2]);
+    printf("%.16e %.16e %.16e\n", l[0] + h[0], l[1] + h[1], l[2] + h[2]);
+    printf("%.16e %.16e %.16e\n\n\n", l[0] + h[0], l[1], l[2] + h[2]);
+
+    printf("%.16e %.16e %.16e\n", l[0], l[1], l[2]);
+    printf("%.16e %.16e %.16e\n", l[0], l[1], l[2] + h[2]);
+    printf("%.16e %.16e %.16e\n", l[0] + h[0], l[1], l[2] + h[2]);
+    printf("%.16e %.16e %.16e\n\n\n", l[0] + h[0], l[1], l[2]);
+
+    printf("%.16e %.16e %.16e\n", l[0], l[1] + h[1], l[2]);
+    printf("%.16e %.16e %.16e\n", l[0], l[1] + h[1], l[2] + h[2]);
+    printf("%.16e %.16e %.16e\n", l[0] + h[0], l[1] + h[1], l[2] + h[2]);
+    printf("%.16e %.16e %.16e\n\n\n", l[0] + h[0], l[1] + h[1], l[2]);
+
+    if (!c->split) {
+      for (int k = 0; k < c->count; k++)
+        printf("0 0 0 %.16e %.16e %.16e\n", c->parts[k].x[0], c->parts[k].x[1],
+               c->parts[k].x[2]);
+      printf("\n\n");
+    }
+    /* else
+        for ( int k = 0 ; k < 8 ; k++ )
+            if ( c->progeny[k] != NULL )
+                map_cells_plot( c->progeny[k] , data ); */
+  }
+}
+
+/**
+ * @brief Mapping function for checking if each part is in its box.
+ */
+
+/* void map_check ( struct part *p , struct cell *c , void *data ) {
+
+    if ( p->x[0] < c->loc[0] || p->x[0] > c->loc[0]+c->h[0] ||
+         p->x[0] < c->loc[0] || p->x[0] > c->loc[0]+c->h[0] ||
+         p->x[0] < c->loc[0] || p->x[0] > c->loc[0]+c->h[0] )
+        printf( "map_check: particle %i is outside of its box.\n" , p->id );
+
+    } */
+
+/**
+ * @brief Mapping function for neighbour count.
+ */
+
+void map_cellcheck(struct cell *c, void *data) {
+
+  int k, *count = (int *)data;
+  struct part *p;
+
+  __sync_fetch_and_add(count, c->count);
+
+  /* Loop over all parts and check if they are in the cell. */
+  for (k = 0; k < c->count; k++) {
+    p = &c->parts[k];
+    if (p->x[0] < c->loc[0] || p->x[1] < c->loc[1] || p->x[2] < c->loc[2] ||
+        p->x[0] > c->loc[0] + c->h[0] || p->x[1] > c->loc[1] + c->h[1] ||
+        p->x[2] > c->loc[2] + c->h[2]) {
+      printf(
+          "map_cellcheck: particle at [ %.16e %.16e %.16e ] outside of cell [ "
+          "%.16e %.16e %.16e ] - [ %.16e %.16e %.16e ].\n",
+          p->x[0], p->x[1], p->x[2], c->loc[0], c->loc[1], c->loc[2],
+          c->loc[0] + c->h[0], c->loc[1] + c->h[1], c->loc[2] + c->h[2]);
+      error("particle out of bounds!");
+    }
+  }
+}
+
+/**
+ * @brief Mapping function for maxdepth cell count.
+ */
+
+void map_maxdepth(struct cell *c, void *data) {
+
+  int maxdepth = ((int *)data)[0];
+  int *count = &((int *)data)[1];
+
+  // printf( "%e\n" , p->count );
+
+  if (c->depth == maxdepth) *count += 1;
+}
+
+/**
+ * @brief Mapping function for neighbour count.
+ */
+
+void map_count(struct part *p, struct cell *c, void *data) {
+
+  double *wcount = (double *)data;
+
+  // printf( "%i %e %e\n" , p->id , p->count , p->count_dh );
+
+  *wcount += p->density.wcount;
+}
+
+void map_wcount_min(struct part *p, struct cell *c, void *data) {
+
+  struct part **p2 = (struct part **)data;
+
+  if (p->density.wcount < (*p2)->density.wcount) *p2 = p;
+}
+
+void map_wcount_max(struct part *p, struct cell *c, void *data) {
+
+  struct part **p2 = (struct part **)data;
+
+  if (p->density.wcount > (*p2)->density.wcount) *p2 = p;
+}
+
+void map_h_min(struct part *p, struct cell *c, void *data) {
+
+  struct part **p2 = (struct part **)data;
+
+  if (p->h < (*p2)->h) *p2 = p;
+}
+
+void map_h_max(struct part *p, struct cell *c, void *data) {
+
+  struct part **p2 = (struct part **)data;
+
+  if (p->h > (*p2)->h) *p2 = p;
+}
+
+/**
+ * @brief Mapping function for neighbour count.
+ */
+
+void map_icount(struct part *p, struct cell *c, void *data) {
+
+  // int *count = (int *)data;
+
+  // printf( "%i\n" , p->icount );
+
+  // *count += p->icount;
+}
+
+/**
+ * @brief Mapping function to print the particle position.
+ */
+
+void map_dump(struct part *p, struct cell *c, void *data) {
+
+  double *shift = (double *)data;
+
+  printf("%g\t%g\t%g\n", p->x[0] - shift[0], p->x[1] - shift[1],
+         p->x[2] - shift[2]);
+}
diff --git a/src/map.h b/src/map.h
new file mode 100644
index 0000000000000000000000000000000000000000..0fe04ad0158499626a16a0b18637ff190cf59c97
--- /dev/null
+++ b/src/map.h
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * This file is part of SWIFT.
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+ *                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ ******************************************************************************/
+
+
+/* Includes. */
+#ifndef SWIFT_MAP_H
+#define SWIFT_MAP_H
+
+#include "part.h"
+#include "cell.h"
+
+void map_cells_plot(struct cell *c, void *data);
+void map_check(struct part *p, struct cell *c, void *data);
+void map_cellcheck(struct cell *c, void *data);
+void map_maxdepth(struct cell *c, void *data);
+void map_count(struct part *p, struct cell *c, void *data);
+void map_wcount_min(struct part *p, struct cell *c, void *data);
+void map_wcount_max(struct part *p, struct cell *c, void *data);
+void map_h_min(struct part *p, struct cell *c, void *data);
+void map_h_max(struct part *p, struct cell *c, void *data);
+void map_icount(struct part *p, struct cell *c, void *data);
+void map_dump(struct part *p, struct cell *c, void *data);
+
+#endif /* SWIFT_MAP_H */
diff --git a/src/multipole.c b/src/multipole.c
index 439e9cd5f0218bddf28d228de6eb3bb14a2d6735..fc4701fead68e64e8742730325931282f80e8934 100644
--- a/src/multipole.c
+++ b/src/multipole.c
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2013 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2013 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
diff --git a/src/multipole.h b/src/multipole.h
index ffa5d713f507b85f6ae9216cfe81d4fc49316345..91ba6df965ce9d3b088d538411b7f0a8555ba0e4 100644
--- a/src/multipole.h
+++ b/src/multipole.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2013 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2013 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
diff --git a/src/parallel_io.c b/src/parallel_io.c
index 8ffd59a591f4f035d912156be08c33ef90b5d8ee..acba06748a9fcd1c082f81cb940a3d6301ab8a9e 100644
--- a/src/parallel_io.c
+++ b/src/parallel_io.c
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
  *                    Matthieu Schaller (matthieu.schaller@durham.ac.uk).
  *
  * This program is free software: you can redistribute it and/or modify
@@ -47,14 +47,14 @@
  * @param type The #DATA_TYPE of the attribute.
  * @param N The number of particles.
  * @param dim The dimension of the data (1 for scalar, 3 for vector)
- * @param part_c A (char*) pointer on the first occurence of the field of
+ * @param part_c A (char*) pointer on the first occurrence of the field of
  *interest in the parts array
  * @param importance If COMPULSORY, the data must be present in the IC file. If
  *OPTIONAL, the array will be zeroed when the data is not present.
  *
- * @todo A better version using HDF5 hyperslabs to read the file directly into
+ * @todo A better version using HDF5 hyper-slabs to read the file directly into
  *the part array
- * will be written once the strucutres have been stabilized.
+ * will be written once the structures have been stabilized.
  *
  * Calls #error() if an error occurs.
  */
@@ -102,7 +102,7 @@ void readArrayBackEnd(hid_t grp, char* name, enum DATA_TYPE type, int N,
   temp = malloc(N * dim * typeSize);
   if (temp == NULL) error("Unable to allocate memory for temporary buffer");
 
-  /* Prepare information for hyperslab */
+  /* Prepare information for hyper-slab */
   if (dim > 1) {
     rank = 2;
     shape[0] = N;
@@ -120,7 +120,7 @@ void readArrayBackEnd(hid_t grp, char* name, enum DATA_TYPE type, int N,
   /* Create data space in memory */
   h_memspace = H5Screate_simple(rank, shape, NULL);
 
-  /* Select hyperslab in file */
+  /* Select hyper-slab in file */
   h_filespace = H5Dget_space(h_data);
   H5Sselect_hyperslab(h_filespace, H5S_SELECT_SET, offsets, NULL, shape, NULL);
 
@@ -185,7 +185,7 @@ void readArrayBackEnd(hid_t grp, char* name, enum DATA_TYPE type, int N,
  * in the file.
  *
  * @warning Can not read snapshot distributed over more than 1 file !!!
- * @todo Read snaphsots distributed in more than one file.
+ * @todo Read snapshots distributed in more than one file.
  *
  * Calls #error() if an error occurs.
  *
@@ -309,14 +309,14 @@ void read_ic_parallel(char* fileName, double dim[3], struct part** parts,
  * @param dim The dimension of the data (1 for scalar, 3 for vector)
  * @param N_total Total number of particles across all cores
  * @param offset Offset in the array where this mpi task starts writing
- * @param part_c A (char*) pointer on the first occurence of the field of
+ * @param part_c A (char*) pointer on the first occurrence of the field of
  *interest in the parts array
  * @param us The UnitSystem currently in use
  * @param convFactor The UnitConversionFactor for this array
  *
- * @todo A better version using HDF5 hyperslabs to write the file directly from
+ * @todo A better version using HDF5 hyper-slabs to write the file directly from
  *the part array
- * will be written once the strucutres have been stabilized.
+ * will be written once the structures have been stabilized.
  *
  * Calls #error() if an error occurs.
  */
@@ -416,8 +416,8 @@ void writeArrayBackEnd(hid_t grp, char* fileName, FILE* xmfFile, char* name,
   conversionString(buffer, us, convFactor);
   writeAttribute_d(h_data, "CGS conversion factor",
                    conversionFactor(us, convFactor));
-  writeAttribute_f(h_data, "h-scale exponant", hFactor(us, convFactor));
-  writeAttribute_f(h_data, "a-scale exponant", aFactor(us, convFactor));
+  writeAttribute_f(h_data, "h-scale exponent", hFactor(us, convFactor));
+  writeAttribute_f(h_data, "a-scale exponent", aFactor(us, convFactor));
   writeAttribute_s(h_data, "Conversion factor", buffer);
 
   /* Free and close everything */
@@ -441,7 +441,7 @@ void writeArrayBackEnd(hid_t grp, char* fileName, FILE* xmfFile, char* name,
  * @param N_total Total number of particles across all cores
  * @param mpi_rank The MPI task rank calling the function
  * @param offset Offset in the array where this mpi task starts writing
- * @param part A (char*) pointer on the first occurence of the field of interest
+ * @param part A (char*) pointer on the first occurrence of the field of interest
  *in the parts array
  * @param field The name (code name) of the field to read from.
  * @param us The UnitSystem currently in use
@@ -511,7 +511,7 @@ void write_output_parallel(struct engine* e, struct UnitSystem* us,
   MPI_Bcast(&N_total_d, 1, MPI_DOUBLE, mpi_size - 1, comm);
   if (N_total_d > 1.e15)
     error(
-        "Error while computing the offest for parallel output: Simulation has "
+        "Error while computing the offset for parallel output: Simulation has "
         "more than 10^15 particles.\n");
   N_total = (long long)N_total_d;
   offset = (long long)offset_d;
diff --git a/src/parallel_io.h b/src/parallel_io.h
index fa46a230ab73e52a3b471dc0b157f5cf0f99ef73..5ee2714a18dbabdd5fc8c07c0b444e04a87ad4f8 100644
--- a/src/parallel_io.h
+++ b/src/parallel_io.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Matthieu Schaller (matthieu.schaller@durham.ac.uk).
+ * Copyright (c) 2012 Matthieu Schaller (matthieu.schaller@durham.ac.uk).
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
diff --git a/src/part.h b/src/part.h
index 380c2dedb2d7847c0d0efe937d0b24feb0a736f0..37070bdce52d8b5ef7b3ebca7dadb5ef918c85b5 100644
--- a/src/part.h
+++ b/src/part.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
diff --git a/src/proxy.c b/src/proxy.c
index 257a11593d674a3f8a5674670ac3a12f203e1eb2..7d2e546bf945ca18c2195ea2801d1b2058cb2f58 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2013 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2013 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
@@ -142,7 +142,7 @@ void proxy_addcell_in(struct proxy *p, struct cell *c) {
   if (p->nr_cells_in == p->size_cells_in) {
     p->size_cells_in *= proxy_buffgrow;
     if ((temp = malloc(sizeof(struct cell *) * p->size_cells_in)) == NULL)
-      error("Failed to allocate ingoing cell list.");
+      error("Failed to allocate incoming cell list.");
     memcpy(temp, p->cells_in, sizeof(struct cell *) * p->nr_cells_in);
     free(p->cells_in);
     p->cells_in = temp;
diff --git a/src/proxy.h b/src/proxy.h
index 8cb08d0a66095597227b52b317f3808190cdc45f..3cd33e0f0819ee1ecac53213630445b39c809dea 100644
--- a/src/proxy.h
+++ b/src/proxy.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2013 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2013 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
@@ -40,7 +40,7 @@ struct proxy {
   /* ID of the node this proxy represents. */
   int mynodeID, nodeID;
 
-  /* Incomming cells. */
+  /* Incoming cells. */
   struct cell **cells_in;
   struct pcell *pcells_in;
   int nr_cells_in, size_cells_in, size_pcells_in;
diff --git a/src/queue.c b/src/queue.c
index 3fa0096bf0fab8ecc6ec2508d5a7c2529451e54d..4e5330518c3d067a3e8a8ce7806e3560a41cc8ef 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
diff --git a/src/queue.h b/src/queue.h
index 533007684fa41a4a25a10a14c504358926d0fe06..d81627b4c4a709498c31c6c6152d3650388020e2 100644
--- a/src/queue.h
+++ b/src/queue.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
diff --git a/src/runner.c b/src/runner.c
index 826c60e15534cb42230a01ca4c8ae4e240cb04cc..de6c3987c0bd8e16dc99def6bb2fa9c1ff3d12e1 100644
--- a/src/runner.c
+++ b/src/runner.c
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
@@ -536,7 +536,7 @@ void runner_doghost(struct runner *r, struct cell *c) {
       /* Get a direct pointer on the part. */
       p = &parts[pid[i]];
 
-      /* Is this part within the timestep? */
+      /* Is this part within the time step? */
       if (p->dt <= dt_step) {
 
         /* Some smoothing length multiples. */
@@ -620,7 +620,7 @@ void runner_doghost(struct runner *r, struct cell *c) {
         alpha_dot = (const_viscosity_alpha_min - p->alpha) / tau +
                     (const_viscosity_alpha_max - p->alpha) * S;
 
-        /* Update particle's viscosity paramter */
+        /* Update particle's viscosity parameter */
         p->alpha += alpha_dot * p->dt;
 #endif
 
@@ -932,7 +932,7 @@ void runner_dokick1(struct runner *r, struct cell *c) {
 
   }
 
-  /* Otherwise, agregate data from children. */
+  /* Otherwise, aggregate data from children. */
   else {
 
     /* Init with the first non-null child. */
@@ -1045,7 +1045,7 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) {
       xp->v_hdt[2] = (v_hdt[2] += dt * a[2]);
       xp->u_hdt = (u_hdt += dt * u_dt);
 
-      /* Move the particles with the velocitie at the half-step. */
+      /* Move the particles with the velocity at the half-step. */
       p->x[0] = x[0] += dt * v_hdt[0];
       p->x[1] = x[1] += dt * v_hdt[1];
       p->x[2] = x[2] += dt * v_hdt[2];
@@ -1103,7 +1103,7 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) {
 
   }
 
-  /* Otherwise, agregate data from children. */
+  /* Otherwise, aggregate data from children. */
   else {
 
     /* Init with the first non-null child. */
diff --git a/src/runner.h b/src/runner.h
index 30e75bd6ad21d45baf328adef23d2b500015ce9b..1ad348ccceea1549fe0d04bf7cac06dfed9b19bc 100644
--- a/src/runner.h
+++ b/src/runner.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
diff --git a/src/runner_doiact.h b/src/runner_doiact.h
index 017529cc94021ee9ea38ce543ac8a3c4dea2e1db..8653a70c79a9b87616d95ac323d701f60b04b36e 100644
--- a/src/runner_doiact.h
+++ b/src/runner_doiact.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
@@ -1299,7 +1299,7 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj) {
 
           } else {
 
-            /* Add this interaction to the non-summetric queue. */
+            /* Add this interaction to the non-symmetric queue. */
             r2q1[icount1] = r2;
             dxq1[3 * icount1 + 0] = dx[0];
             dxq1[3 * icount1 + 1] = dx[1];
@@ -1818,7 +1818,7 @@ void DOSUB1(struct runner *r, struct cell *ci, struct cell *cj, int sid,
 
     }
 
-    /* Otherwsie, compute self-interaction. */
+    /* Otherwise, compute self-interaction. */
     else
       DOSELF1(r, ci);
 
@@ -2093,7 +2093,7 @@ void DOSUB2(struct runner *r, struct cell *ci, struct cell *cj, int sid,
 
     }
 
-    /* Otherwsie, compute self-interaction. */
+    /* Otherwise, compute self-interaction. */
     else
       DOSELF2(r, ci);
 
@@ -2382,7 +2382,7 @@ void DOSUB_SUBSET(struct runner *r, struct cell *ci, struct part *parts,
 
     }
 
-    /* Otherwsie, compute self-interaction. */
+    /* Otherwise, compute self-interaction. */
     else
       DOSELF_SUBSET(r, ci, parts, ind, count);
 
diff --git a/src/runner_doiact_grav.h b/src/runner_doiact_grav.h
index 98fd23585768b4594e84099177a5d291912230cb..ee5c31cc15f42dc5a3f2b154df0aba2fa09210b5 100644
--- a/src/runner_doiact_grav.h
+++ b/src/runner_doiact_grav.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2013 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2013 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
@@ -241,7 +241,7 @@ void runner_dograv_up(struct runner *r, struct cell *c) {
 
 /**
  * @brief Compute the recursive downward sweep, i.e. apply the multipole
- *        accelleration on all the particles.
+ *        acceleration on all the particles.
  *
  * @param r The #runner.
  * @param c The top-level #cell.
@@ -254,7 +254,7 @@ void runner_dograv_down(struct runner *r, struct cell *c) {
   /* Split? */
   if (c->split) {
 
-    /* Apply this cell's accelleration on the multipoles below. */
+    /* Apply this cell's acceleration on the multipoles below. */
     for (int k = 0; k < 8; k++)
       if (c->progeny[k] != NULL) {
         struct multipole *mp = &c->progeny[k]->multipole;
@@ -272,7 +272,7 @@ void runner_dograv_down(struct runner *r, struct cell *c) {
   /* No, leaf node. */
   else {
 
-    /* Apply the multipole accelleration to all gparts. */
+    /* Apply the multipole acceleration to all gparts. */
     for (int k = 0; k < c->gcount; k++) {
       struct gpart *p = &c->gparts[k];
       p->a[0] += m->a[0];
@@ -590,7 +590,7 @@ void runner_dosub_grav(struct runner *r, struct cell *ci, struct cell *cj,
     theta = (dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]) /
             (ci->h[0] * ci->h[0] + ci->h[1] * ci->h[1] + ci->h[2] * ci->h[2]);
 
-    /* Split the interacton? */
+    /* Split the interaction? */
     if (theta < const_theta_max * const_theta_max) {
 
       /* Are both ci and cj split? */
diff --git a/src/runner_iact.h b/src/runner_iact.h
index e1561132af3fff847989af34c268dfb1069ed40d..f1828eaf106b0ee94435fcaa90ea1feb3485b5d8 100644
--- a/src/runner_iact.h
+++ b/src/runner_iact.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
@@ -421,7 +421,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_force(
   /* Apply balsara switch */
   Pi_ij *= (pi->force.balsara + pj->force.balsara);
 
-  /* Termal conductivity */
+  /* Thermal conductivity */
   v_sig_u = sqrtf(2.f * (const_hydro_gamma - 1.f) *
                   fabs(rhoi * pi->u - rhoj * pj->u) / (rhoi + rhoj));
   tc = const_conductivity_alpha * v_sig_u / (rhoi + rhoj);
@@ -622,7 +622,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_vec_force(
   Pi_ij.v = balsara.v * alpha_ij.v * v_sig.v * omega_ij.v / (pirho.v + pjrho.v);
   Pi_ij.v *= (wi_dr.v + wj_dr.v);
 
-  /* Termal conductivity */
+  /* Thermal conductivity */
   v_sig_u.v = vec_sqrt(vec_set1(2.f * (const_hydro_gamma - 1.f)) *
                        vec_fabs(pirho.v * piu.v - pjrho.v * pju.v) /
                        (pirho.v + pjrho.v));
@@ -737,7 +737,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force(
   /* Apply balsara switch */
   Pi_ij *= (pi->force.balsara + pj->force.balsara);
 
-  /* Termal conductivity */
+  /* Thermal conductivity */
   v_sig_u = sqrtf(2.f * (const_hydro_gamma - 1.f) *
                   fabs(rhoi * pi->u - rhoj * pj->u) / (rhoi + rhoj));
   tc = const_conductivity_alpha * v_sig_u / (rhoi + rhoj);
@@ -929,7 +929,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_vec_force(
   Pi_ij.v = balsara.v * alpha_ij.v * v_sig.v * omega_ij.v / (pirho.v + pjrho.v);
   Pi_ij.v *= (wi_dr.v + wj_dr.v);
 
-  /* Termal conductivity */
+  /* Thermal conductivity */
   v_sig_u.v = vec_sqrt(vec_set1(2.f * (const_hydro_gamma - 1.f)) *
                        vec_fabs(pirho.v * piu.v - pjrho.v * pju.v) /
                        (pirho.v + pjrho.v));
diff --git a/src/runner_iact_grav.h b/src/runner_iact_grav.h
index 2fd30c1c3854db56564300f0a3e1a13a6dc31251..e62be446e8263bf02e3fd73f902b28cb1c3b16cf 100644
--- a/src/runner_iact_grav.h
+++ b/src/runner_iact_grav.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2013 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2013 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
@@ -53,7 +53,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_grav(
   /* Scale the acceleration. */
   acc *= const_G * ir * ir * ir;
 
-  /* Aggregate the accellerations. */
+  /* Aggregate the accelerations. */
   for (k = 0; k < 3; k++) {
     w = acc * dx[k];
     pi->a[k] -= w * mj;
@@ -101,7 +101,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_vec_grav(
   /* Scale the acceleration. */
   acc.v *= vec_set1(const_G) * ir.v * ir.v * ir.v;
 
-  /* Aggregate the accellerations. */
+  /* Aggregate the accelerations. */
   for (k = 0; k < 3; k++) {
     w.v = acc.v * dx[k].v;
     ai.v = w.v * mj.v;
diff --git a/src/runner_iact_legacy.h b/src/runner_iact_legacy.h
index 42044caafc8686f4ce5f639bacc16f297f266868..5716cf4a7a84a9d9fcd4cef38a307e483389d4ab 100644
--- a/src/runner_iact_legacy.h
+++ b/src/runner_iact_legacy.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/src/scheduler.c b/src/scheduler.c
index 70aaba282b32efb8e3538ef1d45caa14df062fdf..43bea8379ca4eb7c0353bebfd4ad87b6838a7aca 100644
--- a/src/scheduler.c
+++ b/src/scheduler.c
@@ -1,6 +1,7 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ *                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
@@ -176,7 +177,7 @@ void scheduler_splittasks(struct scheduler *s) {
           /* Take a step back (we're going to recycle the current task)... */
           redo = 1;
 
-          /* Add the self taks. */
+          /* Add the self task. */
           for (k = 0; ci->progeny[k] == NULL; k++)
             ;
           t->ci = ci->progeny[k];
@@ -598,7 +599,7 @@ void scheduler_splittasks(struct scheduler *s) {
           /* Ignore this task if the cell has no gparts. */
           if (ci->gcount == 0 || cj->gcount == 0) t->type = task_type_none;
 
-          /* Split the interacton? */
+          /* Split the interaction? */
           else if (theta < const_theta_max * const_theta_max) {
 
             /* Are both ci and cj split? */
@@ -706,7 +707,7 @@ void scheduler_ranktasks(struct scheduler *s) {
   struct task *t, *tasks = s->tasks;
   int *tid = s->tasks_ind, nr_tasks = s->nr_tasks;
 
-  /* Run throught the tasks and get all the waits right. */
+  /* Run through the tasks and get all the waits right. */
   for (i = 0, k = 0; k < nr_tasks; k++) {
     tid[k] = k;
     for (j = 0; j < tasks[k].nr_unlock_tasks; j++)
@@ -764,7 +765,7 @@ void scheduler_reset(struct scheduler *s, int size) {
   /* Do we need to re-allocate? */
   if (size > s->size) {
 
-    /* Free exising task lists if necessary. */
+    /* Free existing task lists if necessary. */
     if (s->tasks != NULL) free(s->tasks);
     if (s->tasks_ind != NULL) free(s->tasks_ind);
 
@@ -782,6 +783,7 @@ void scheduler_reset(struct scheduler *s, int size) {
   s->nr_tasks = 0;
   s->tasks_next = 0;
   s->waiting = 0;
+  s->mask = 0;
 
   /* Set the task pointers in the queues. */
   for (k = 0; k < s->nr_queues; k++) s->queues[k].tasks = s->tasks;
@@ -803,7 +805,7 @@ void scheduler_reweight(struct scheduler *s) {
   float wscale = 0.001;
   // ticks tic;
 
-  /* Run throught the tasks backwards and set their waits and
+  /* Run through the tasks backwards and set their waits and
      weights. */
   // tic = getticks();
   for (k = nr_tasks - 1; k >= 0; k--) {
@@ -887,13 +889,16 @@ void scheduler_start(struct scheduler *s, unsigned int mask) {
   struct task *t, *tasks = s->tasks;
   // ticks tic;
 
-  /* Run throught the tasks and set their waits. */
+  /* Store the mask */
+  s->mask = mask;
+
+  /* Run through the tasks and set their waits. */
   // tic = getticks();
   for (k = nr_tasks - 1; k >= 0; k--) {
     t = &tasks[tid[k]];
     t->wait = 0;
     t->rid = -1;
-    if (!((1 << t->type) & mask) || t->skip) continue;
+    if (!((1 << t->type) & s->mask) || t->skip) continue;
     for (j = 0; j < t->nr_unlock_tasks; j++)
       atomic_inc(&t->unlock_tasks[j]->wait);
   }
@@ -901,13 +906,13 @@ void scheduler_start(struct scheduler *s, unsigned int mask) {
   // CPU_TPS * 1000 );
 
   /* Don't enqueue link tasks directly. */
-  mask &= ~(1 << task_type_link);
+  s->mask &= ~(1 << task_type_link);
 
   /* Loop over the tasks and enqueue whoever is ready. */
   // tic = getticks();
   for (k = 0; k < nr_tasks; k++) {
     t = &tasks[tid[k]];
-    if (((1 << t->type) & mask) && !t->skip) {
+    if (((1 << t->type) & s->mask) && !t->skip) {
       if (t->wait == 0) {
         scheduler_enqueue(s, t);
         pthread_cond_broadcast(&s->sleep_cond);
@@ -933,14 +938,16 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) {
   int err;
 #endif
 
-  /* Ignore skipped tasks. */
-  if (t->skip || atomic_cas(&t->rid, -1, 0) != -1) return;
+  /* Ignore skipped tasks and tasks not in the mask. */
+  if (t->skip || ((1 << t->type) & ~(s->mask) && t->type != task_type_link) ||
+      atomic_cas(&t->rid, -1, 0) != -1)
+    return;
 
   /* If this is an implicit task, just pretend it's done. */
   if (t->implicit) {
     for (int j = 0; j < t->nr_unlock_tasks; j++) {
       struct task *t2 = t->unlock_tasks[j];
-      if (atomic_dec(&t2->wait) == 1 && !t2->skip) scheduler_enqueue(s, t2);
+      if (atomic_dec(&t2->wait) == 1) scheduler_enqueue(s, t2);
     }
   }
 
@@ -974,7 +981,7 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) {
           MPI_Error_string(err, buff, &len);
           error("Failed to emit irecv for particle data (%s).", buff);
         }
-        // message( "recieving %i parts with tag=%i from %i to %i." ,
+        // message( "receiving %i parts with tag=%i from %i to %i." ,
         //     t->ci->count , t->flags , t->ci->nodeID , s->nodeID );
         // fflush(stdout);
         qid = 1 % s->nr_queues;
@@ -1039,7 +1046,7 @@ struct task *scheduler_done(struct scheduler *s, struct task *t) {
     int res = atomic_dec(&t2->wait);
     if (res < 1) {
       error("Negative wait!");
-    } else if (res == 1 && !t2->skip) {
+    } else if (res == 1) {
       scheduler_enqueue(s, t2);
     }
   }
@@ -1071,38 +1078,38 @@ struct task *scheduler_done(struct scheduler *s, struct task *t) {
 
 struct task *scheduler_unlock(struct scheduler *s, struct task *t) {
 
-  int k, res;
-  struct task *t2, *next = NULL;
-
   /* Loop through the dependencies and add them to a queue if
      they are ready. */
-  for (k = 0; k < t->nr_unlock_tasks; k++) {
-    t2 = t->unlock_tasks[k];
-    if ((res = atomic_dec(&t2->wait)) < 1) error("Negative wait!");
-    if (res == 1 && !t2->skip) scheduler_enqueue(s, t2);
+  for (int k = 0; k < t->nr_unlock_tasks; k++) {
+    struct task *t2 = t->unlock_tasks[k];
+    int res = atomic_dec(&t2->wait);
+    if (res < 1) {
+      error("Negative wait!");
+    } else if (res == 1) {
+      scheduler_enqueue(s, t2);
+    }
   }
 
   /* Task definitely done. */
   if (!t->implicit) {
     t->toc = getticks();
     pthread_mutex_lock(&s->sleep_mutex);
-    if (next == NULL) atomic_dec(&s->waiting);
+    atomic_dec(&s->waiting);
     pthread_cond_broadcast(&s->sleep_cond);
     pthread_mutex_unlock(&s->sleep_mutex);
   }
 
-  /* Start the clock on the follow-up task. */
-  if (next != NULL) next->tic = getticks();
-
-  /* Return the next best task. */
-  return next;
+  /* Return the next best task. Note that we currently do not
+     implement anything that does this, as getting it to respect
+     priorities is too tricky and currently unnecessary. */
+  return NULL;
 }
 
 /**
  * @brief Get a task, preferably from the given queue.
  *
  * @param s The #scheduler.
- * @param qid The ID of the prefered #queue.
+ * @param qid The ID of the preferred #queue.
  * @param super the super-cell
  *
  * @return A pointer to a #task or @c NULL if there are no available tasks.
@@ -1133,7 +1140,7 @@ struct task *scheduler_gettask(struct scheduler *s, int qid,
         if (res != NULL) break;
       }
 
-      /* If unsucessful, try stealing from the other queues. */
+      /* If unsuccessful, try stealing from the other queues. */
       if (s->flags & scheduler_flag_steal) {
         int count = 0, qids[nr_queues];
         for (k = 0; k < nr_queues; k++)
diff --git a/src/scheduler.h b/src/scheduler.h
index 620b712885a1653397b3e9fd0e632cc0e562cf19..82371f9c3d1b88e613ead7df7246ae44e700dfdf 100644
--- a/src/scheduler.h
+++ b/src/scheduler.h
@@ -1,6 +1,7 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2013 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2013 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ *                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
@@ -50,6 +51,9 @@ struct scheduler {
   /* Scheduler flags. */
   unsigned int flags;
 
+  /* Scheduler mask */
+  unsigned int mask;
+
   /* Number of queues in this scheduler. */
   int nr_queues;
 
diff --git a/src/serial_io.c b/src/serial_io.c
index 19b895ca5be87aac8e39c1c1f81ad911e294d522..c2c19faef8c8a9ea8d3021a8bc07217ee17f8b89 100644
--- a/src/serial_io.c
+++ b/src/serial_io.c
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
  *                    Matthieu Schaller (matthieu.schaller@durham.ac.uk).
  *
  * This program is free software: you can redistribute it and/or modify
@@ -55,14 +55,14 @@
  * @param type The #DATA_TYPE of the attribute.
  * @param N The number of particles.
  * @param dim The dimension of the data (1 for scalar, 3 for vector)
- * @param part_c A (char*) pointer on the first occurence of the field of
+ * @param part_c A (char*) pointer on the first occurrence of the field of
  *interest in the parts array
  * @param importance If COMPULSORY, the data must be present in the IC file. If
  *OPTIONAL, the array will be zeroed when the data is not present.
  *
- * @todo A better version using HDF5 hyperslabs to read the file directly into
+ * @todo A better version using HDF5 hyper-slabs to read the file directly into
  *the part array
- * will be written once the strucutres have been stabilized.
+ * will be written once the structures have been stabilized.
  *
  * Calls #error() if an error occurs.
  */
@@ -111,7 +111,7 @@ void readArrayBackEnd(hid_t grp, char* name, enum DATA_TYPE type, int N,
   temp = malloc(N * dim * typeSize);
   if (temp == NULL) error("Unable to allocate memory for temporary buffer");
 
-  /* Prepare information for hyperslab */
+  /* Prepare information for hyper-slab */
   if (dim > 1) {
     rank = 2;
     shape[0] = N;
@@ -129,7 +129,7 @@ void readArrayBackEnd(hid_t grp, char* name, enum DATA_TYPE type, int N,
   /* Create data space in memory */
   h_memspace = H5Screate_simple(rank, shape, NULL);
 
-  /* Select hyperslab in file */
+  /* Select hyper-slab in file */
   h_filespace = H5Dget_space(h_data);
   H5Sselect_hyperslab(h_filespace, H5S_SELECT_SET, offsets, NULL, shape, NULL);
 
@@ -203,7 +203,7 @@ void readArrayBackEnd(hid_t grp, char* name, enum DATA_TYPE type, int N,
  * in the file.
  *
  * @warning Can not read snapshot distributed over more than 1 file !!!
- * @todo Read snaphsots distributed in more than one file.
+ * @todo Read snapshots distributed in more than one file.
  *
  * Calls #error() if an error occurs.
  *
@@ -228,7 +228,7 @@ void read_ic_serial(char* fileName, double dim[3], struct part** parts, int* N,
     /* message("Opening file '%s' as IC.", fileName); */
     h_file = H5Fopen(fileName, H5F_ACC_RDONLY, H5P_DEFAULT);
     if (h_file < 0)
-      error("Error while opening file '%s' for inital read.", fileName);
+      error("Error while opening file '%s' for initial read.", fileName);
 
     /* Open header to read simulation properties */
     /* message("Reading runtime parameters..."); */
@@ -383,8 +383,8 @@ void prepareArray(hid_t grp, char* fileName, FILE* xmfFile, char* name,
   conversionString(buffer, us, convFactor);
   writeAttribute_d(h_data, "CGS conversion factor",
                    conversionFactor(us, convFactor));
-  writeAttribute_f(h_data, "h-scale exponant", hFactor(us, convFactor));
-  writeAttribute_f(h_data, "a-scale exponant", aFactor(us, convFactor));
+  writeAttribute_f(h_data, "h-scale exponent", hFactor(us, convFactor));
+  writeAttribute_f(h_data, "a-scale exponent", aFactor(us, convFactor));
   writeAttribute_s(h_data, "Conversion factor", buffer);
 
   H5Dclose(h_data);
@@ -401,7 +401,7 @@ void prepareArray(hid_t grp, char* fileName, FILE* xmfFile, char* name,
  * @param type The #DATA_TYPE of the array.
  * @param N The number of particles to write.
  * @param dim The dimension of the data (1 for scalar, 3 for vector)
- * @param part_c A (char*) pointer on the first occurence of the field of
+ * @param part_c A (char*) pointer on the first occurrence of the field of
  *interest in the parts array
  * @param us The UnitSystem currently in use
  * @param convFactor The UnitConversionFactor for this array
@@ -432,7 +432,7 @@ void writeArrayBackEnd(hid_t grp, char* name, enum DATA_TYPE type, int N,
   for (i = 0; i < N; ++i)
     memcpy(&temp_c[i * copySize], part_c + i * partSize, copySize);
 
-  /* Construct information for the hyperslab */
+  /* Construct information for the hyper-slab */
   if (dim > 1) {
     rank = 2;
     shape[0] = N;
@@ -488,7 +488,7 @@ void writeArrayBackEnd(hid_t grp, char* name, enum DATA_TYPE type, int N,
  * @param type The #DATA_TYPE of the array.
  * @param N The number of particles to write.
  * @param dim The dimension of the data (1 for scalar, 3 for vector)
- * @param part A (char*) pointer on the first occurence of the field of interest
+ * @param part A (char*) pointer on the first occurrence of the field of interest
  *in the parts array
  * @param field The name (code name) of the field to read from.
  * @param us The UnitSystem currently in use
@@ -541,7 +541,7 @@ void write_output_serial(struct engine* e, struct UnitSystem* us, int mpi_rank,
   MPI_Bcast(&N_total_d, 1, MPI_DOUBLE, mpi_size - 1, comm);
   if (N_total_d > 1.e15)
     error(
-        "Error while computing the offest for parallel output: Simulation has "
+        "Error while computing the offset for parallel output: Simulation has "
         "more than 10^15 particles.\n");
   N_total = (long long) N_total_d;
   offset = (long long) offset_d;
diff --git a/src/serial_io.h b/src/serial_io.h
index bb05fc61bdca1b0db36386e6773a034cc17ea6b9..e5ecca9c8cbafbbaf2e555c5c216b494e25cc922 100644
--- a/src/serial_io.h
+++ b/src/serial_io.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Matthieu Schaller (matthieu.schaller@durham.ac.uk).
+ * Copyright (c) 2012 Matthieu Schaller (matthieu.schaller@durham.ac.uk).
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
diff --git a/src/single_io.c b/src/single_io.c
index 0bdd9049b2dbb1d05479914e3f5e6791f5b4583d..9d3138d0a706e5316e8d58bcbf613f61c04d63fb 100644
--- a/src/single_io.c
+++ b/src/single_io.c
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
  *                    Matthieu Schaller (matthieu.schaller@durham.ac.uk).
  *
  * This program is free software: you can redistribute it and/or modify
@@ -50,14 +50,14 @@
  * @param type The #DATA_TYPE of the attribute.
  * @param N The number of particles.
  * @param dim The dimension of the data (1 for scalar, 3 for vector)
- * @param part_c A (char*) pointer on the first occurence of the field of
+ * @param part_c A (char*) pointer on the first occurrence of the field of
  *interest in the parts array
  * @param importance If COMPULSORY, the data must be present in the IC file. If
  *OPTIONAL, the array will be zeroed when the data is not present.
  *
- * @todo A better version using HDF5 hyperslabs to read the file directly into
+ * @todo A better version using HDF5 hyper-slabs to read the file directly into
  *the part array
- * will be written once the strucutres have been stabilized.
+ * will be written once the structures have been stabilized.
  *
  * Calls #error() if an error occurs.
  */
@@ -159,7 +159,7 @@ void readArrayBackEnd(hid_t grp, char* name, enum DATA_TYPE type, int N,
  * in the file.
  *
  * @warning Can not read snapshot distributed over more than 1 file !!!
- * @todo Read snaphsots distributed in more than one file.
+ * @todo Read snapshots distributed in more than one file.
  *
  * Calls #error() if an error occurs.
  *
@@ -257,14 +257,14 @@ void read_ic_single(char* fileName, double dim[3], struct part** parts, int* N,
  * @param type The #DATA_TYPE of the array.
  * @param N The number of particles to write.
  * @param dim The dimension of the data (1 for scalar, 3 for vector)
- * @param part_c A (char*) pointer on the first occurence of the field of
+ * @param part_c A (char*) pointer on the first occurrence of the field of
  *interest in the parts array
  * @param us The UnitSystem currently in use
  * @param convFactor The UnitConversionFactor for this array
  *
- * @todo A better version using HDF5 hyperslabs to write the file directly from
+ * @todo A better version using HDF5 hyper-slabs to write the file directly from
  *the part array
- * will be written once the strucutres have been stabilized.
+ * will be written once the structures have been stabilized.
  *
  * Calls #error() if an error occurs.
  */
@@ -334,8 +334,8 @@ void writeArrayBackEnd(hid_t grp, char* fileName, FILE* xmfFile, char* name,
   conversionString(buffer, us, convFactor);
   writeAttribute_d(h_data, "CGS conversion factor",
                    conversionFactor(us, convFactor));
-  writeAttribute_f(h_data, "h-scale exponant", hFactor(us, convFactor));
-  writeAttribute_f(h_data, "a-scale exponant", aFactor(us, convFactor));
+  writeAttribute_f(h_data, "h-scale exponent", hFactor(us, convFactor));
+  writeAttribute_f(h_data, "a-scale exponent", aFactor(us, convFactor));
   writeAttribute_s(h_data, "Conversion factor", buffer);
 
   /* Free and close everything */
@@ -354,7 +354,7 @@ void writeArrayBackEnd(hid_t grp, char* fileName, FILE* xmfFile, char* name,
  * @param type The #DATA_TYPE of the array.
  * @param N The number of particles to write.
  * @param dim The dimension of the data (1 for scalar, 3 for vector)
- * @param part A (char*) pointer on the first occurence of the field of interest
+ * @param part A (char*) pointer on the first occurrence of the field of interest
  *in the parts array
  * @param field The name (code name) of the field to read from.
  * @param us The UnitSystem currently in use
diff --git a/src/single_io.h b/src/single_io.h
index 91d229178bbd45df3ba358172d1f52c70008adb7..f6689901106a2cd5d85a873d4047e1d21edd3547 100644
--- a/src/single_io.h
+++ b/src/single_io.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Matthieu Schaller (matthieu.schaller@durham.ac.uk).
+ * Copyright (c) 2012 Matthieu Schaller (matthieu.schaller@durham.ac.uk).
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
diff --git a/src/space.c b/src/space.c
index 578ea0c945429eaf7b05b37be802e22beb1b1ff0..dff22dba2f57d072a8a760371cad4db19586b66a 100644
--- a/src/space.c
+++ b/src/space.c
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
@@ -182,7 +182,7 @@ void space_regrid(struct space *s, double cell_max, int verbose) {
     float buff;
     if (MPI_Allreduce(&h_max, &buff, 1, MPI_FLOAT, MPI_MAX, MPI_COMM_WORLD) !=
         MPI_SUCCESS)
-      error("Failed to aggreggate the rebuild flag accross nodes.");
+      error("Failed to aggregate the rebuild flag across nodes.");
     h_max = buff;
   }
 #endif
@@ -750,7 +750,7 @@ void gparts_sort(struct gpart *gparts, int *ind, int N, int min, int max) {
       } else {
 
         /* Recurse on the right? */
-        if (jj + 1 < j && pivot + 1 < max) {
+        if (pivot + 1 < max) {
           qid = (last++) % qstack_size;
           qstack[qid].i = jj + 1;
           qstack[qid].j = j;
@@ -1010,7 +1010,7 @@ void space_split(struct space *s, struct cell *c) {
     c->dt_max = dt_max;
   }
 
-  /* Set ownership accorind to the start of the parts array. */
+  /* Set ownership according to the start of the parts array. */
   c->owner = ((c->parts - s->parts) % s->nr_parts) * s->nr_queues / s->nr_parts;
 }
 
@@ -1106,7 +1106,7 @@ struct cell *space_getcell(struct space *s) {
 void space_init(struct space *s, double dim[3], struct part *parts, int N,
                 int periodic, double h_max, int verbose) {
 
-  /* Store eveything in the space. */
+  /* Store everything in the space. */
   s->dim[0] = dim[0];
   s->dim[1] = dim[1];
   s->dim[2] = dim[2];
diff --git a/src/space.h b/src/space.h
index 4f37275b716d37644d7c6bd648a58cc70a3d76e2..1c8cba3b9626ed760c309e8178d4a1e2790007ac 100644
--- a/src/space.h
+++ b/src/space.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
diff --git a/src/swift.h b/src/swift.h
index b302bca9b007cec47c96e1ab07770a3a3dc84966..1b7d86c769bb33f2677d81a25c286d88cbc2782c 100644
--- a/src/swift.h
+++ b/src/swift.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
@@ -32,6 +32,7 @@
 #include "engine.h"
 #include "error.h"
 #include "lock.h"
+#include "map.h"
 #include "multipole.h"
 #include "parallel_io.h"
 #include "part.h"
@@ -44,6 +45,7 @@
 #include "task.h"
 #include "timers.h"
 #include "units.h"
+#include "tools.h"
 #include "version.h"
 
 #ifdef LEGACY_GADGET2_SPH
diff --git a/src/task.c b/src/task.c
index 0186013c4d56cafbdf1049e50b3b529ca964abc6..9b802843e80b2c449d925c0bedb3179c24041d77 100644
--- a/src/task.c
+++ b/src/task.c
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
diff --git a/src/task.h b/src/task.h
index c300bcda7bdd73539dd2ff2284e8fcf032b6d270..9be92767c2df2fb2b70410c418df263a98d76864 100644
--- a/src/task.h
+++ b/src/task.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
diff --git a/src/timers.c b/src/timers.c
index 01a77d7804241f108b092f7d6857c90be3861cd0..2501d347c8cea608650ece4c2883dab85ceee058 100644
--- a/src/timers.c
+++ b/src/timers.c
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
diff --git a/src/timers.h b/src/timers.h
index 38ca81222ffb33b1558dcc4d7ee3a0cc1a71cd20..8c6443825d7df5152c36cedd40aa3dd46727fb69 100644
--- a/src/timers.h
+++ b/src/timers.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
diff --git a/src/tools.c b/src/tools.c
new file mode 100644
index 0000000000000000000000000000000000000000..5f8abcbeb6d339bedc3df71e5ccf651535b8bc0c
--- /dev/null
+++ b/src/tools.c
@@ -0,0 +1,285 @@
+/*******************************************************************************
+ * This file is part of SWIFT.
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+ *                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
+ * Copyright (c) 2015 Peter W. Draper (p.w.draper@durham.ac.uk)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ ******************************************************************************/
+
+
+#include <math.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <stdio.h>
+
+#include "error.h"
+#include "part.h"
+#include "cell.h"
+#include "tools.h"
+#include "swift.h"
+
+
+/**
+ *  Factorize a given integer, attempts to keep larger pair of factors.
+ */
+void factor(int value, int *f1, int *f2) {
+  int j;
+  int i;
+
+  j = (int)sqrt(value);
+  for (i = j; i > 0; i--) {
+    if ((value % i) == 0) {
+      *f1 = i;
+      *f2 = value / i;
+      break;
+    }
+  }
+}
+
+
+
+/**
+ * @brief Compute the average number of pairs per particle using
+ *      a brute-force O(N^2) computation.
+ *
+ * @param dim The space dimensions.
+ * @param parts The #part array.
+ * @param N The number of parts.
+ * @param periodic Periodic boundary conditions flag.
+ */
+
+void pairs_n2(double *dim, struct part *__restrict__ parts, int N,
+              int periodic) {
+
+  int i, j, k, count = 0;
+  // int mj, mk;
+  // double maxratio = 1.0;
+  double r2, dx[3], rho = 0.0;
+  double rho_max = 0.0, rho_min = 100;
+
+  /* Loop over all particle pairs. */
+  for (j = 0; j < N; j++) {
+    if (j % 1000 == 0) {
+      printf("pairs_n2: j=%i.\n", j);
+      fflush(stdout);
+    }
+    for (k = j + 1; k < N; k++) {
+      for (i = 0; i < 3; i++) {
+        dx[i] = parts[j].x[i] - parts[k].x[i];
+        if (periodic) {
+          if (dx[i] < -dim[i] / 2)
+            dx[i] += dim[i];
+          else if (dx[i] > dim[i] / 2)
+            dx[i] -= dim[i];
+        }
+      }
+      r2 = dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2];
+      if (r2 < parts[j].h * parts[j].h || r2 < parts[k].h * parts[k].h) {
+        runner_iact_density(r2, NULL, parts[j].h, parts[k].h, &parts[j],
+                            &parts[k]);
+        /* if ( parts[j].h / parts[k].h > maxratio )
+            {
+            maxratio = parts[j].h / parts[k].h;
+            mj = j; mk = k;
+            }
+        else if ( parts[k].h / parts[j].h > maxratio )
+            {
+            maxratio = parts[k].h / parts[j].h;
+            mj = j; mk = k;
+            } */
+      }
+    }
+  }
+
+  /* Aggregate the results. */
+  for (k = 0; k < N; k++) {
+    // count += parts[k].icount;
+    rho += parts[k].density.wcount;
+    rho_min = fmin(parts[k].density.wcount, rho_min);
+    rho_min = fmax(parts[k].density.wcount, rho_max);
+  }
+
+  /* Dump the result. */
+  printf("pairs_n2: avg. density per part is %.3f (nr. pairs %.3f).\n",
+         rho / N + 32.0 / 3, ((double)count) / N);
+  printf("pairs_n2: densities are in [ %e , %e ].\n", rho_min / N + 32.0 / 3,
+         rho_max / N + 32.0 / 3);
+  /* printf( "pairs_n2: maximum ratio between parts %i [%e,%e,%e] and %i
+     [%e,%e,%e] is %.3f/%.3f\n" ,
+      mj , parts[mj].x[0] , parts[mj].x[1] , parts[mj].x[2] ,
+      mk , parts[mk].x[0] , parts[mk].x[1] , parts[mk].x[2] ,
+      parts[mj].h , parts[mk].h ); fflush(stdout); */
+  fflush(stdout);
+}
+
+void pairs_single_density(double *dim, long long int pid,
+                          struct part *__restrict__ parts, int N,
+                          int periodic) {
+
+  int i, k;
+  // int mj, mk;
+  // double maxratio = 1.0;
+  double r2, dx[3];
+  float fdx[3];
+  struct part p;
+  // double ih = 12.0/6.25;
+
+  /* Find "our" part. */
+  for (k = 0; k < N && parts[k].id != pid; k++)
+    ;
+  if (k == N) error("Part not found.");
+  p = parts[k];
+  printf("pairs_single: part[%i].id == %lli.\n", k, pid);
+
+  p.rho = 0.0;
+  p.density.wcount = 0.0;
+  // p.icount = 0;
+  p.rho_dh = 0.0;
+
+  /* Loop over all particle pairs. */
+  for (k = 0; k < N; k++) {
+    if (parts[k].id == p.id) continue;
+    for (i = 0; i < 3; i++) {
+      dx[i] = p.x[i] - parts[k].x[i];
+      if (periodic) {
+        if (dx[i] < -dim[i] / 2)
+          dx[i] += dim[i];
+        else if (dx[i] > dim[i] / 2)
+          dx[i] -= dim[i];
+      }
+      fdx[i] = dx[i];
+    }
+    r2 = fdx[0] * fdx[0] + fdx[1] * fdx[1] + fdx[2] * fdx[2];
+    if (r2 < p.h * p.h) {
+      runner_iact_nonsym_density(r2, fdx, p.h, parts[k].h, &p, &parts[k]);
+      /* printf( "pairs_simple: interacting particles %lli [%i,%i,%i] and %lli
+         [%i,%i,%i], r=%e.\n" ,
+          pid , (int)(p.x[0]*ih) , (int)(p.x[1]*ih) , (int)(p.x[2]*ih) ,
+          parts[k].id , (int)(parts[k].x[0]*ih) , (int)(parts[k].x[1]*ih) ,
+         (int)(parts[k].x[2]*ih) ,
+          sqrtf(r2) ); */
+    }
+  }
+
+  /* Dump the result. */
+  printf("pairs_single: wcount of part %lli (h=%e) is %f.\n", p.id, p.h,
+         p.density.wcount + 32.0 / 3);
+  fflush(stdout);
+}
+
+void pairs_single_grav(double *dim, long long int pid,
+                       struct gpart *__restrict__ parts, int N, int periodic) {
+
+  int i, k;
+  // int mj, mk;
+  // double maxratio = 1.0;
+  double r2, dx[3];
+  float fdx[3], a[3] = {0.0, 0.0, 0.0}, aabs[3] = {0.0, 0.0, 0.0};
+  struct gpart pi, pj;
+  // double ih = 12.0/6.25;
+
+  /* Find "our" part. */
+  for (k = 0; k < N; k++)
+    if ((parts[k].id > 0 && parts[k].part->id == pid) || parts[k].id == -pid)
+      break;
+  if (k == N) error("Part not found.");
+  pi = parts[k];
+  pi.a[0] = 0.0f;
+  pi.a[1] = 0.0f;
+  pi.a[2] = 0.0f;
+
+  /* Loop over all particle pairs. */
+  for (k = 0; k < N; k++) {
+    if (parts[k].id == pi.id) continue;
+    pj = parts[k];
+    for (i = 0; i < 3; i++) {
+      dx[i] = pi.x[i] - pj.x[i];
+      if (periodic) {
+        if (dx[i] < -dim[i] / 2)
+          dx[i] += dim[i];
+        else if (dx[i] > dim[i] / 2)
+          dx[i] -= dim[i];
+      }
+      fdx[i] = dx[i];
+    }
+    r2 = fdx[0] * fdx[0] + fdx[1] * fdx[1] + fdx[2] * fdx[2];
+    runner_iact_grav(r2, fdx, &pi, &pj);
+    a[0] += pi.a[0];
+    a[1] += pi.a[1];
+    a[2] += pi.a[2];
+    aabs[0] += fabsf(pi.a[0]);
+    aabs[1] += fabsf(pi.a[1]);
+    aabs[2] += fabsf(pi.a[2]);
+    pi.a[0] = 0.0f;
+    pi.a[1] = 0.0f;
+    pi.a[2] = 0.0f;
+  }
+
+  /* Dump the result. */
+  message(
+      "acceleration on gpart %lli is a=[ %e %e %e ], |a|=[ %.2e %.2e %.2e ].\n",
+      pi.part->id, a[0], a[1], a[2], aabs[0], aabs[1], aabs[2]);
+}
+
+
+/**
+ * @brief Test the density function by dumping it for two random parts.
+ *
+ * @param N number of intervals in [0,1].
+ */
+
+void density_dump(int N) {
+
+  int k;
+  float r2[4] = {0.0f, 0.0f, 0.0f, 0.0f}, hi[4], hj[4];
+  struct part *pi[4], *pj[4], Pi[4], Pj[4];
+
+  /* Init the interaction parameters. */
+  for (k = 0; k < 4; k++) {
+    Pi[k].mass = 1.0f;
+    Pi[k].rho = 0.0f;
+    Pi[k].density.wcount = 0.0f;
+    Pj[k].mass = 1.0f;
+    Pj[k].rho = 0.0f;
+    Pj[k].density.wcount = 0.0f;
+    hi[k] = 1.0;
+    hj[k] = 1.0;
+    pi[k] = &Pi[k];
+    pj[k] = &Pj[k];
+  }
+
+  for (k = 0; k <= N; k++) {
+    r2[3] = r2[2];
+    r2[2] = r2[1];
+    r2[1] = r2[0];
+    r2[0] = ((float)k) / N;
+    Pi[0].density.wcount = 0;
+    Pj[0].density.wcount = 0;
+    runner_iact_density(r2[0], NULL, hi[0], hj[0], &Pi[0], &Pj[0]);
+    printf(" %e %e %e", r2[0], Pi[0].density.wcount, Pj[0].density.wcount);
+    Pi[0].density.wcount = 0;
+    Pj[0].density.wcount = 0;
+    Pi[1].density.wcount = 0;
+    Pj[1].density.wcount = 0;
+    Pi[2].density.wcount = 0;
+    Pj[2].density.wcount = 0;
+    Pi[3].density.wcount = 0;
+    Pj[3].density.wcount = 0;
+    runner_iact_vec_density(r2, NULL, hi, hj, pi, pj);
+    printf(" %e %e %e %e\n", Pi[0].density.wcount, Pi[1].density.wcount,
+           Pi[2].density.wcount, Pi[3].density.wcount);
+  }
+}
diff --git a/src/tools.h b/src/tools.h
new file mode 100644
index 0000000000000000000000000000000000000000..7354a51030fef3a1fc8445afce770f56d5866fd6
--- /dev/null
+++ b/src/tools.h
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * This file is part of SWIFT.
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+ *                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
+ * Copyright (c) 2015 Peter W. Draper (p.w.draper@durham.ac.uk)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ ******************************************************************************/
+
+void factor(int value, int *f1, int *f2);
+void density_dump(int N);
+void pairs_single_grav(double *dim, long long int pid,
+                       struct gpart *__restrict__ parts, int N, int periodic);
+void pairs_single_density(double *dim, long long int pid,
+                          struct part *__restrict__ parts, int N,
+                          int periodic);
+
+void pairs_n2(double *dim, struct part *__restrict__ parts, int N,
+              int periodic);
+
diff --git a/src/units.c b/src/units.c
index e802d73355c9f387ec5f40ba71e46d564a15ff25..8c9fd14452e9e1fdfe029ac89d22d7cd43aa0ef7 100644
--- a/src/units.c
+++ b/src/units.c
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
  *                    Matthieu Schaller (matthieu.schaller@durham.ac.uk).
  *
  * This program is free software: you can redistribute it and/or modify
@@ -300,7 +300,7 @@ float aFactor(struct UnitSystem* us, enum UnitConversionFactor unit) {
 }
 
 /**
- * @brief Returns a string containg the exponants of the base units making up
+ * @brief Returns a string containing the exponents of the base units making up
  * the conversion factors
  */
 void conversionString(char* buffer, struct UnitSystem* us,
@@ -316,7 +316,7 @@ void conversionString(char* buffer, struct UnitSystem* us,
  * @brief Returns the conversion factor for a given unit (expressed in terms of
  * the 5 fundamental units) in the chosen unit system
  * @param us The unit system used
- * @param baseUnitsExponants The exponant of each base units required to form
+ * @param baseUnitsExponants The exponent of each base units required to form
  * the desired quantity. See conversionFactor() for a working example
  */
 double generalConversionFactor(struct UnitSystem* us,
@@ -334,7 +334,7 @@ double generalConversionFactor(struct UnitSystem* us,
  * @brief Returns the h factor exponentiation for a given unit (expressed in
  * terms of the 5 fundamental units)
  * @param us The unit system used
- * @param baseUnitsExponants The exponant of each base units required to form
+ * @param baseUnitsExponants The exponent of each base units required to form
  * the desired quantity. See conversionFactor() for a working example
  */
 float generalhFactor(struct UnitSystem* us, float baseUnitsExponants[5]) {
@@ -351,7 +351,7 @@ float generalhFactor(struct UnitSystem* us, float baseUnitsExponants[5]) {
  * @brief Returns the scaling factor exponentiation for a given unit (expressed
  * in terms of the 5 fundamental units)
  * @param us The unit system used
- * @param baseUnitsExponants The exponant of each base units required to form
+ * @param baseUnitsExponants The exponent of each base units required to form
  * the desired quantity. See conversionFactor() for a working example
  */
 float generalaFactor(struct UnitSystem* us, float baseUnitsExponants[5]) {
@@ -363,12 +363,12 @@ float generalaFactor(struct UnitSystem* us, float baseUnitsExponants[5]) {
 }
 
 /**
- * @brief Returns a string containg the exponants of the base units making up
+ * @brief Returns a string containing the exponents of the base units making up
  * the conversion factors (expressed in terms of the 5 fundamental units)
  * @param buffer The buffer in which to write (The buffer must be long enough,
  * 140 chars at most)
- * @param us The UnistSystem in use.
- * @param baseUnitsExponants The exponant of each base units required to form
+ * @param us The UnitsSystem in use.
+ * @param baseUnitsExponants The exponent of each base units required to form
  * the desired quantity. See conversionFactor() for a working example
  */
 void generalConversionString(char* buffer, struct UnitSystem* us,
diff --git a/src/units.h b/src/units.h
index 0523247b04f1d09c9974bae5afab8070590d77b1..1b977529784c1ef3069e1e932b16fd0b87073786 100644
--- a/src/units.h
+++ b/src/units.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Matthieu Schaller (matthieu.schaller@durham.ac.uk).
+ * Copyright (c) 2012 Matthieu Schaller (matthieu.schaller@durham.ac.uk).
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
@@ -143,14 +143,14 @@ float generalaFactor(struct UnitSystem* us, float baseUnitsExponants[5]);
 float aFactor(struct UnitSystem* us, enum UnitConversionFactor unit);
 
 /**
- * @brief Returns a string containg the exponants of the base units making up
+ * @brief Returns a string containing the exponents of the base units making up
  * the conversion factors (expressed in terms of the 5 fundamental units)
  */
 void generalConversionString(char* buffer, struct UnitSystem* us,
                              float baseUnitsExponants[5]);
 
 /**
- * @brief Returns a string containg the exponants of the base units making up
+ * @brief Returns a string containing the exponents of the base units making up
  * the conversion factors
  */
 void conversionString(char* buffer, struct UnitSystem* us,
diff --git a/src/vector.h b/src/vector.h
index cddc933ab1c64e537ce68fcb0a77e74bbe6818d3..8629b39725ebb7d800047116f45fb7ec6c6e7a1d 100644
--- a/src/vector.h
+++ b/src/vector.h
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
  *               2015 Matthieu Schaller (matthieu.schaller@durham.ac.uk)
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4df125851e5c6825974efdcf006c34acb6718f28..00e90f3b86e31a59f5fe9c450daaf71fa795baa7 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,5 +1,5 @@
 # This file is part of SWIFT.
-# Coypright (c) 2015 matthieu.schaller@durham.ac.uk.
+# Copyright (c) 2015 matthieu.schaller@durham.ac.uk.
 # 
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -20,13 +20,17 @@ AM_CFLAGS = -I../src -DCPU_TPS=2.67e9 $(HDF5_CPPFLAGS)
 AM_LDFLAGS = ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS) $(HDF5_LIBS)
 
 # List of programs and scripts to run in the test suite
-TESTS = testGreetings testReading.sh
-
+TESTS = testGreetings testReading.sh testSingle
 
 # List of test programs to compile
-check_PROGRAMS = testGreetings testReading
+check_PROGRAMS = testGreetings testReading testSingle
 
 # Sources for the individual programs
 testGreetings_SOURCES = testGreetings.c
 
 testReading_SOURCES = testReading.c
+
+# Sources for test_single
+testSingle_SOURCES = testSingle.c
+testSingle_CFLAGS = $(MYFLAGS) $(AM_CFLAGS)
+testSingle_LDADD =  ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS) $(HDF5_LIBS)
diff --git a/tests/makeInput.py b/tests/makeInput.py
index 3cb802e381855ee27fd4ec520276b51a900d634a..8d8c07faf1e528869616bf93fbb7ffe8bf196af0 100644
--- a/tests/makeInput.py
+++ b/tests/makeInput.py
@@ -1,6 +1,6 @@
 ###############################################################################
  # This file is part of SWIFT.
- # Coypright (c) 2015 Matthieu Schaller (matthieu.schaller@durham.ac.uk)
+ # Copyright (c) 2015 Matthieu Schaller (matthieu.schaller@durham.ac.uk)
  # 
  # This program is free software: you can redistribute it and/or modify
  # it under the terms of the GNU Lesser General Public License as published
diff --git a/examples/test_single.c b/tests/testSingle.c
similarity index 98%
rename from examples/test_single.c
rename to tests/testSingle.c
index 36c219eebf214feaf775283834578c5a487d5e90..02c52160d0d442496629f1bb3947f89524964fb8 100644
--- a/examples/test_single.c
+++ b/tests/testSingle.c
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * This file is part of SWIFT.
- * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
+ * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
  *                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
  * 
  * This program is free software: you can redistribute it and/or modify