diff --git a/src/atomic.h b/src/atomic.h
index 6374b2b02f9553879be44da25f29bb767db00e56..16b268c4c799cd1ca8c38a3382df912a9d618614 100644
--- a/src/atomic.h
+++ b/src/atomic.h
@@ -19,6 +19,7 @@
 #ifndef SWIFT_ATOMIC_H
 #define SWIFT_ATOMIC_H
 
+/* Includes. */
 #include "inline.h"
 
 #define atomic_add(v, i) __sync_fetch_and_add(v, i)
diff --git a/src/common_io.h b/src/common_io.h
index 0b406b03ec1af7767c4cbfd9a82eaeb2a9ec4142..7aacd9ad6e02b5bf2f9b4dd325d52f0af34d2f4f 100644
--- a/src/common_io.h
+++ b/src/common_io.h
@@ -23,6 +23,7 @@
 /* Config parameters. */
 #include "../config.h"
 
+/* Includes. */
 #include "units.h"
 
 #if defined(HAVE_HDF5)
diff --git a/src/error.h b/src/error.h
index 379eb381203f1a8b1f728c70f29ad68f4c9f738c..e581dcf86ecea9abbc0a116fb041175fd872758c 100644
--- a/src/error.h
+++ b/src/error.h
@@ -20,8 +20,14 @@
 #ifndef SWIFT_ERROR_H
 #define SWIFT_ERROR_H
 
+/* Some standard headers. */
 #include <stdio.h>
 
+/* MPI headers. */
+#ifdef WITH_MPI
+#include <mpi.h>
+#endif
+
 /**
  * @brief Error macro. Prints the message given in argument and aborts.
  *
diff --git a/src/inline.h b/src/inline.h
index a5de828c4aa6857aaf73066043ac402c7133986e..06728cb87f5e342b22d4a4a861cbd83ea6af31d9 100644
--- a/src/inline.h
+++ b/src/inline.h
@@ -17,6 +17,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  ******************************************************************************/
+#ifndef SWIFT_INLINE_H
+#define SWIFT_INLINE_H
 
 /**
  * @brief Defines inline
@@ -28,3 +30,5 @@
 #define INLINE inline
 #endif
 #endif
+
+#endif /* SWIFT_INLINE_H */
diff --git a/src/lock.h b/src/lock.h
index 5924208068de6653d0334dda0b9aaba4847cadee..19a4e74bf82d3b6bb8e305388ca42929cc9d719e 100644
--- a/src/lock.h
+++ b/src/lock.h
@@ -19,6 +19,10 @@
 #ifndef SWIFT_LOCK_H
 #define SWIFT_LOCK_H
 
+/* Some standard headers. */
+#include <pthread.h>
+
+/* Includes. */
 #include "inline.h"
 
 #ifdef PTHREAD_SPINLOCK
diff --git a/src/multipole.h b/src/multipole.h
index b99ece504d7fed5e274fdfbed4e36d9cf8d585eb..690d997a74841593d7c765cbd08c6b7332ae8ca6 100644
--- a/src/multipole.h
+++ b/src/multipole.h
@@ -26,6 +26,7 @@
 #include "inline.h"
 #include "kernel.h"
 #include "part.h"
+#include "const.h"
 
 /* Some constants. */
 #define multipole_order 1
diff --git a/src/parallel_io.h b/src/parallel_io.h
index 035f94c336f55e632faa044ecd4f5de20d445187..b6f2929e4e27df6cf26c65c0052c85cc36de663a 100644
--- a/src/parallel_io.h
+++ b/src/parallel_io.h
@@ -19,8 +19,15 @@
 #ifndef SWIFT_PARALLEL_IO_H
 #define SWIFT_PARALLEL_IO_H
 
+/* MPI headers. */
+#ifdef WITH_MPI
+#include <mpi.h>
+#endif
+
 /* Includes. */
 #include "part.h"
+#include "engine.h"
+#include "units.h"
 
 #if defined(HAVE_HDF5) && defined(WITH_MPI) && defined(HAVE_PARALLEL_HDF5)
 
diff --git a/src/queue.h b/src/queue.h
index 7107fbc468a0ff1467e2984ce166d955d77ffc7f..6298eb1570b6b3ddfa145258738d025398d69a79 100644
--- a/src/queue.h
+++ b/src/queue.h
@@ -21,6 +21,9 @@
 
 /* Includes. */
 #include "cell.h"
+#include "lock.h"
+#include "task.h"
+#include "queue.h"
 
 /* Some constants. */
 #define queue_maxsuper 50
diff --git a/src/runner.h b/src/runner.h
index 70912c72a17928919423217d96c5747fa058a2b8..30e75bd6ad21d45baf328adef23d2b500015ce9b 100644
--- a/src/runner.h
+++ b/src/runner.h
@@ -19,10 +19,16 @@
 #ifndef SWIFT_RUNNER_H
 #define SWIFT_RUNNER_H
 
+/* Some standard headers. */
+#include <pthread.h>
+
 /* Includes. */
 #include "cell.h"
 #include "inline.h"
 
+/* Forward-declare the engine type to avoid cyclic header dependencies. */
+struct engine;
+
 /* Some constants/flags. */
 #define runner_prefetch 0
 
diff --git a/src/runner_iact.h b/src/runner_iact.h
index 747208afc1c547b1469a980d57e9987d30cbd57f..2ed6ce836a91cf67151ac40118be8c77c41e60b0 100644
--- a/src/runner_iact.h
+++ b/src/runner_iact.h
@@ -22,6 +22,7 @@
 
 /* Includes. */
 #include "part.h"
+#include "const.h"
 #include "kernel.h"
 #include "vector.h"
 
diff --git a/src/runner_iact_grav.h b/src/runner_iact_grav.h
index eefa0c7e1c79bcb79b17f6a96accbb728c97054a..2fd30c1c3854db56564300f0a3e1a13a6dc31251 100644
--- a/src/runner_iact_grav.h
+++ b/src/runner_iact_grav.h
@@ -20,6 +20,8 @@
 #ifndef SWIFT_RUNNER_IACT_GRAV_H
 #define SWIFT_RUNNER_IACT_GRAV_H
 
+/* Includes. */
+#include "const.h"
 #include "kernel.h"
 #include "vector.h"
 
diff --git a/src/runner_iact_legacy.h b/src/runner_iact_legacy.h
index 5b42c6de7ffee5e8dee7c3d91a5bbb65c716bfc9..8678093483f6540804ccc2c2f45d8059826ca6ba 100644
--- a/src/runner_iact_legacy.h
+++ b/src/runner_iact_legacy.h
@@ -22,6 +22,7 @@
 
 /* Includes. */
 #include "part.h"
+#include "const.h"
 #include "kernel.h"
 #include "vector.h"
 
diff --git a/src/scheduler.h b/src/scheduler.h
index e358a0cba83cff577a5fc3fd6448dc8400cb48d7..b693c6f1bab1c463419c47497f5868113f850801 100644
--- a/src/scheduler.h
+++ b/src/scheduler.h
@@ -19,8 +19,15 @@
 #ifndef SWIFT_SCHEDULER_H
 #define SWIFT_SCHEDULER_H
 
+/* Some standard headers. */
+#include <pthread.h>
+
 /* Includes. */
 #include "cell.h"
+#include "queue.h"
+#include "task.h"
+#include "lock.h"
+#include "space.h"
 
 /* Some constants. */
 #define scheduler_maxwait 3
diff --git a/src/serial_io.h b/src/serial_io.h
index 3344c0dab319a1dcedb4ef32473064d9955e645a..e963184d428489785c7806b597ac14ef142facee 100644
--- a/src/serial_io.h
+++ b/src/serial_io.h
@@ -19,8 +19,15 @@
 #ifndef SWIFT_SERIAL_IO_H
 #define SWIFT_SERIAL_IO_H
 
+/* MPI headers. */
+#ifdef WITH_MPI
+#include <mpi.h>
+#endif
+
 /* Includes. */
 #include "part.h"
+#include "engine.h"
+#include "units.h"
 
 #if defined(HAVE_HDF5) && defined(WITH_MPI) && !defined(HAVE_PARALLEL_HDF5)
 
diff --git a/src/single_io.h b/src/single_io.h
index 673dfd7386faa1379687e477bcc72b4cf5404487..61e9a7e6aaa4c816e37545fd004faaf54d00be10 100644
--- a/src/single_io.h
+++ b/src/single_io.h
@@ -19,6 +19,11 @@
 #ifndef SWIFT_SINGLE_IO_H
 #define SWIFT_SINGLE_IO_H
 
+/* Includes. */
+#include "part.h"
+#include "engine.h"
+#include "units.h"
+
 #if defined(HAVE_HDF5) && !defined(WITH_MPI)
 
 void read_ic_single(char* fileName, double dim[3], struct part** parts, int* N,
diff --git a/src/space.h b/src/space.h
index 08790b8712b4047ee1b2cc1fd9f28e010cf91e76..32c991637adc88b4a18b8b843ae17fa58548fb05 100644
--- a/src/space.h
+++ b/src/space.h
@@ -23,6 +23,9 @@
 #include "part.h"
 #include "cell.h"
 
+/* Forward-declare the engine to avoid cyclic includes. */
+struct engine;
+
 /* Some constants. */
 #define space_maxdepth 10
 #define space_cellallocchunk 1000
diff --git a/src/timers.h b/src/timers.h
index 3c2f584e35049531fc7c42349c666e98a0a004c6..38ca81222ffb33b1558dcc4d7ee3a0cc1a71cd20 100644
--- a/src/timers.h
+++ b/src/timers.h
@@ -19,6 +19,8 @@
 #ifndef SWIFT_TIMERS_H
 #define SWIFT_TIMERS_H
 
+/* Includes. */
+#include "cycle.h"
 #include "inline.h"
 
 /* The timers themselves. */