diff --git a/examples/main.c b/examples/main.c
index 2abbef1e5da3423e60370c9d61da4062ce692dba..8d7e613d4ff8316d70d8187a6d4a09dddd736df3 100644
--- a/examples/main.c
+++ b/examples/main.c
@@ -535,7 +535,7 @@ int main(int argc, char *argv[]) {
             if (!e.sched.tasks[l].skip && !e.sched.tasks[l].implicit) {
               fprintf(
                   file_thread, " %03i %i %i %i %i %lli %lli %i %i %i %i %i\n",
-                  myrank, e.sched.tasks[l].last_rid, e.sched.tasks[l].type,
+                  myrank, e.sched.tasks[l].rid, e.sched.tasks[l].type,
                   e.sched.tasks[l].subtype, (e.sched.tasks[l].cj == NULL),
                   e.sched.tasks[l].tic, e.sched.tasks[l].toc,
                   (e.sched.tasks[l].ci != NULL) ? e.sched.tasks[l].ci->count
@@ -571,7 +571,7 @@ int main(int argc, char *argv[]) {
         if (!e.sched.tasks[l].skip && !e.sched.tasks[l].implicit)
           fprintf(
               file_thread, " %i %i %i %i %lli %lli %i %i %i %i\n",
-              e.sched.tasks[l].last_rid, e.sched.tasks[l].type,
+              e.sched.tasks[l].rid, e.sched.tasks[l].type,
               e.sched.tasks[l].subtype, (e.sched.tasks[l].cj == NULL),
               e.sched.tasks[l].tic, e.sched.tasks[l].toc,
               (e.sched.tasks[l].ci == NULL) ? 0 : e.sched.tasks[l].ci->count,
diff --git a/src/runner.c b/src/runner.c
index f7c061c145a982e544439732bc5ad92febfc6afd..96027b4588eb855f7235ed3b30d478735e41c791 100644
--- a/src/runner.c
+++ b/src/runner.c
@@ -1132,7 +1132,6 @@ void *runner_main(void *data) {
       struct cell *ci = t->ci;
       struct cell *cj = t->cj;
       t->rid = r->cpuid;
-      t->last_rid = r->cpuid;
 
       /* Different types of tasks... */
       switch (t->type) {
@@ -1211,6 +1210,7 @@ void *runner_main(void *data) {
         case task_type_kick_fixdt:
           runner_do_kick_fixdt(r, ci, 1);
           break;
+#ifdef WITH_MPI
         case task_type_send:
           if (t->subtype == task_subtype_tend) {
             free(t->buff);
@@ -1224,6 +1224,7 @@ void *runner_main(void *data) {
             runner_do_recv_cell(r, ci, 1);
           }
           break;
+#endif
         case task_type_grav_mm:
           runner_do_grav_mm(r, t->ci, 1);
           break;
diff --git a/src/scheduler.c b/src/scheduler.c
index 88e448b5046c78208a9a66b695221ac8b73b5d47..ef4d19107fb48684ca299f286436a155a6fe0151 100644
--- a/src/scheduler.c
+++ b/src/scheduler.c
@@ -704,7 +704,6 @@ struct task *scheduler_addtask(struct scheduler *s, enum task_types type,
   t->toc = 0;
   t->nr_unlock_tasks = 0;
   t->rid = -1;
-  t->last_rid = -1;
 
   /* Add an index for it. */
   // lock_lock( &s->lock );
diff --git a/src/task.c b/src/task.c
index f80068d465802f75f952c1a6c02c76bc7aa0512c..2cecce9f066727c9059b08764df647bd8f0f3901 100644
--- a/src/task.c
+++ b/src/task.c
@@ -46,7 +46,6 @@
 #include "inline.h"
 #include "lock.h"
 
-/* Task type names. */
 const char *taskID_names[task_type_count] = {
     "none",       "sort",    "self",         "pair",          "sub_self",
     "sub_pair",   "init",    "ghost",        "extra_ghost",   "kick",
@@ -58,6 +57,9 @@ const char *subtaskID_names[task_subtype_count] = {
 
 /**
  * @brief Computes the overlap between the parts array of two given cells.
+ *
+ * @param ci The first #cell.
+ * @param cj The second #cell.
  */
 __attribute__((always_inline)) INLINE static size_t task_cell_overlap_part(
     const struct cell *ci, const struct cell *cj) {
@@ -77,6 +79,9 @@ __attribute__((always_inline)) INLINE static size_t task_cell_overlap_part(
 
 /**
  * @brief Computes the overlap between the gparts array of two given cells.
+ *
+ * @param ci The first #cell.
+ * @param cj The second #cell.
  */
 __attribute__((always_inline)) INLINE static size_t task_cell_overlap_gpart(
     const struct cell *ci, const struct cell *cj) {
diff --git a/src/task.h b/src/task.h
index d174bad4fac62332b3d2c43997be4ddbf794ea34..c0c9e47ee4ca221f9f960256e9208c749ae523ea 100644
--- a/src/task.h
+++ b/src/task.h
@@ -23,15 +23,15 @@
 #ifndef SWIFT_TASK_H
 #define SWIFT_TASK_H
 
+#include "../config.h"
+
 /* Includes. */
 #include "cell.h"
 #include "cycle.h"
 
-/* Some constants. */
-#define task_maxwait 3
-#define task_maxunlock 15
-
-/* The different task types. */
+/**
+ * @brief The different task types.
+ */
 enum task_types {
   task_type_none = 0,
   task_type_sort,
@@ -54,9 +54,9 @@ enum task_types {
   task_type_count
 };
 
-extern const char *taskID_names[];
-
-/* The different task sub-types. */
+/**
+ * @brief The different task sub-types (for pairs, selfs and sub-tasks).
+ */
 enum task_subtypes {
   task_subtype_none = 0,
   task_subtype_density,
@@ -67,7 +67,9 @@ enum task_subtypes {
   task_subtype_count
 };
 
-/* The kind of action the task perform */
+/**
+ * @brief The type of particles/objects this task acts upon in a given cell.
+ */
 enum task_actions {
   task_action_none,
   task_action_part,
@@ -77,29 +79,72 @@ enum task_actions {
   task_action_count
 };
 
+/**
+ * @brief Names of the task types.
+ */
+extern const char *taskID_names[];
+
+/**
+ * @brief Names of the task sub-types.
+ */
 extern const char *subtaskID_names[];
 
-/* Data of a task. */
+/**
+ * @brief A task to be run by the #scheduler.
+ */
 struct task {
 
+  /*! Type of the task */
   enum task_types type;
+
+  /*! Sub-type of the task (for the tasks that have one */
   enum task_subtypes subtype;
-  char skip, tight, implicit;
-  int flags, wait, rank, weight;
 
+  /*! Flags used to carry additional information (e.g. sort directions) */
+  int flags;
+
+  /*! Number of unsatisfied dependencies */
+  int wait;
+
+  /*! Rank of a task in the order */
+  int rank;
+
+  /*! Weight of the task */
+  int weight;
+
+  /*! Pointers to the cells this task acts upon */
   struct cell *ci, *cj;
 
-  void *buff;
+  /*! ID of the queue or runner owning this task */
+  int rid;
+
+  /*! Number of tasks unlocked by this one */
+  int nr_unlock_tasks;
+
+  /*! List of tasks unlocked by this one */
+  struct task **unlock_tasks;
 
 #ifdef WITH_MPI
+
+  /*! Buffer for this task's communications */
+  void *buff;
+
+  /*! MPI request corresponding to this task */
   MPI_Request req;
+
 #endif
 
-  int rid, last_rid;
+  /*! Start and end time of this task */
   ticks tic, toc;
 
-  int nr_unlock_tasks;
-  struct task **unlock_tasks;
+  /*! Should the scheduler skip this task ? */
+  char skip;
+
+  /*! Does this task require the particles to be tightly in the cell ? */
+  char tight;
+
+  /*! Is this task implicit (i.e. does not do anything) ? */
+  char implicit;
 };
 
 /* Function prototypes. */
diff --git a/src/units.h b/src/units.h
index d189933993fdb195120d5b961c60211fef51b1d1..9adaa7dc621edafe0c1f097b8c5202a2f017e41d 100644
--- a/src/units.h
+++ b/src/units.h
@@ -29,25 +29,26 @@
  * @brief The unit system used internally.
  *
  * This structure contains the conversion factors to the 7 cgs base units to the
- *internal units.
- * It is used everytime a conversion is performed or an i/o function is called.
- *
+ * internal units. It is used everytime a conversion is performed or an i/o
+ * function is called.
  **/
 struct UnitSystem {
-  double UnitMass_in_cgs; /*< Conversion factor from grams to internal mass
-                             units */
 
-  double UnitLength_in_cgs; /*< Conversion factor from centimeters to internal
-                               length units. */
+  /*! Conversion factor from grams to internal mass units */
+  double UnitMass_in_cgs; 
+
+  /*! Conversion factor from centimeters to internal length unit */
+  double UnitLength_in_cgs; 
 
-  double UnitTime_in_cgs; /*< Conversion factor from seconds to internal time
-                             units. */
+  /*! Conversion factor from seconds to internal time units */
+  double UnitTime_in_cgs; 
 
-  double UnitCurrent_in_cgs; /*< Conversion factor from Ampere to internal
-                                current units. */
+  /*! Conversion factor from Ampere to internal current units */
+  double UnitCurrent_in_cgs; 
 
-  double UnitTemperature_in_cgs; /*< Conversion factor from Kelvins to internal
-                                    temperature units. */
+  /*! Conversion factor from Kelvins to internal temperature units. */
+  double UnitTemperature_in_cgs; 
+                                    
 };
 
 /**