diff --git a/examples/main.c b/examples/main.c
index fb3e4c24f8c8cba0f0e74220f1a7cee7933cda68..8cf02680f06711b6401e3d833af6d149337d2db1 100644
--- a/examples/main.c
+++ b/examples/main.c
@@ -56,179 +56,6 @@
 #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
diff --git a/src/Makefile.am b/src/Makefile.am
index 46841c6394f5c6c024f1428a06d1025fa6604962..9fa133c8b9d64dfdde195903590c6d2bba869d78 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -35,12 +35,12 @@ 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
 
 # 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
 
 # Include files for distribution, not installation.
 noinst_HEADERS = atomic.h cycle.h error.h inline.h kernel.h vector.h \
diff --git a/src/map.c b/src/map.c
new file mode 100644
index 0000000000000000000000000000000000000000..1ebc01265cf5b135c7ab788799440fdc7a3abdee
--- /dev/null
+++ b/src/map.c
@@ -0,0 +1,199 @@
+/*******************************************************************************
+ * 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 "map.h"
+#include "error.h"
+#include <stdio.h>
+#include <stdlib.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..ac3fdb2c9cc00270862eca0673fedf043f4f2470
--- /dev/null
+++ b/src/map.h
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * 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. */
+#include "cell.h"
+#include "part.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);
diff --git a/src/swift.h b/src/swift.h
index b302bca9b007cec47c96e1ab07770a3a3dc84966..2dc8b1d6bd8483d194259303a904870a418c5f23 100644
--- a/src/swift.h
+++ b/src/swift.h
@@ -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"