diff --git a/src/cell.h b/src/cell.h
index 73f49498353ab587df04e6eee13e2594632f7848..d71df6fe4e478682ab0c2ef7d944d8d64acfe875 100644
--- a/src/cell.h
+++ b/src/cell.h
@@ -348,7 +348,7 @@ struct cell {
     /*! Do any of this cell's sub-cells need to be sorted? */
     char do_sub_sort;
 
-  #ifdef SWIFT_DEBUG_CHECKS
+#ifdef SWIFT_DEBUG_CHECKS
 
     /*! Last (integer) time the cell's sort arrays were updated. */
     integertime_t ti_sort;
@@ -469,6 +469,9 @@ struct cell {
     /*! Linked list of the tasks computing this cell's star density. */
     struct link *density;
 
+    /*! The task computing this cell's sorts. */
+    struct task *sorts;
+
     /*! Max smoothing length in this cell. */
     double h_max;
 
@@ -490,6 +493,30 @@ struct cell {
     /*! Values of dx_max before the drifts, used for sub-cell tasks. */
     float dx_max_part_old;
 
+    /*! Maximum particle movement in this cell since the last sort. */
+    float dx_max_sort;
+
+    /*! Values of dx_max_sort before the drifts, used for sub-cell tasks. */
+    float dx_max_sort_old;
+
+    /*! Bit mask of sort directions that will be needed in the next timestep. */
+    unsigned int requires_sorts;
+
+    /*! Pointer for the sorted indices. */
+    struct entry *sort[13];
+
+    /*! Bit-mask indicating the sorted directions */
+    unsigned int sorted;
+
+    /*! Bit mask of sorts that need to be computed for this cell. */
+    unsigned int do_sort;
+
+    /*! Do any of this cell's sub-cells need to be sorted? */
+    char do_sub_sort;
+
+    /*! Maximum end of (integer) time step in this cell for gravity tasks. */
+    integertime_t ti_end_min;
+
     /*! Number of #spart updated in this cell. */
     int updated;
 
@@ -499,6 +526,11 @@ struct cell {
     /*! Is the #spart data of this cell being used in a sub-cell? */
     int hold;
 
+#ifdef SWIFT_DEBUG_CHECKS
+    /*! Last (integer) time the cell's sort arrays were updated. */
+    integertime_t ti_sort;
+#endif
+
   } stars;
 
 #ifdef WITH_MPI
diff --git a/src/runner.c b/src/runner.c
index 130335c714c434758cb9afb8a81ffb1823c14f37..8b0ac61c2dd49b3879fe31b6bc6caa574dcb49bc 100644
--- a/src/runner.c
+++ b/src/runner.c
@@ -556,7 +556,7 @@ void runner_do_star_formation(struct runner *r, struct cell *c, int timer) {
 
 #ifdef SWIFT_DEBUG_CHECKS
           sp->ti_kick = gp->ti_kick;
-	  gp->ti_drift = sp->ti_drift;
+          gp->ti_drift = sp->ti_drift;
 #endif
 
           /* Set a smoothing length */
diff --git a/src/space.c b/src/space.c
index 2776e549293b98d6e326d914ff33f00b83afb7a3..66cea7a7c55552b0c9ee9a151dc7ef7ed0cec5ab 100644
--- a/src/space.c
+++ b/src/space.c
@@ -252,7 +252,7 @@ void space_rebuild_recycle_mapper(void *map_data, int num_elements,
 #endif
     if (s->with_self_gravity)
       bzero(c->grav.multipole, sizeof(struct gravity_tensors));
-    for (int i = 0; i < 13; i++)
+    for (int i = 0; i < 13; i++) {
       if (c->hydro.sort[i] != NULL) {
         free(c->hydro.sort[i]);
         c->hydro.sort[i] = NULL;