diff --git a/src/cell.c b/src/cell.c
index c1ee647717c4793508c726ca6a0ac5834388e8de..85763ec1605de6a6cba1aa03e1f62f529042cd73 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -71,13 +71,100 @@
 /* Global variables. */
 int cell_next_tag = 0;
 
+/** List of cell pairs for sub-cell recursion. For any sid, the entries in
+ * this array contain the number of sub-cell pairs and the indices and sid
+ * of the sub-cell pairs themselves. */
+struct cell_split_pair cell_split_pairs[13] = {
+    {1, /* (  1 ,  1 ,  1 ) */
+     {{7, 0, 0}}},
+
+    {4, /* (  1 ,  1 ,  0 ) */
+     {{6, 0, 1}, {7, 1, 1}, {6, 1, 0}, {7, 0, 2}}},
+
+    {1, /* (  1 ,  1 , -1 ) */
+     {{6, 1, 2}}},
+
+    {4, /* (  1 ,  0 ,  1 ) */
+     {{5, 0, 3}, {7, 2, 3}, {5, 2, 0}, {7, 0, 6}}},
+
+    {16, /* (  1 ,  0 ,  0 ) */
+     {{4, 0, 4},
+      {5, 0, 5},
+      {6, 0, 7},
+      {7, 0, 8},
+      {4, 1, 3},
+      {5, 1, 4},
+      {6, 1, 6},
+      {7, 1, 7},
+      {4, 2, 1},
+      {5, 2, 2},
+      {6, 2, 4},
+      {7, 2, 5},
+      {4, 3, 0},
+      {5, 3, 1},
+      {6, 3, 3},
+      {7, 3, 4}}},
+
+    {4, /* (  1 ,  0 , -1 ) */
+     {{4, 1, 5}, {6, 3, 5}, {4, 3, 2}, {6, 1, 8}}},
+
+    {1, /* (  1 , -1 ,  1 ) */
+     {{5, 2, 6}}},
+
+    {4, /* (  1 , -1 ,  0 ) */
+     {{4, 3, 6}, {5, 2, 8}, {4, 2, 7}, {5, 3, 7}}},
+
+    {1, /* (  1 , -1 , -1 ) */
+     {{4, 3, 8}}},
+
+    {4, /* (  0 ,  1 ,  1 ) */
+     {{3, 0, 9}, {7, 4, 9}, {3, 4, 0}, {7, 0, 8}}},
+
+    {16, /* (  0 ,  1 ,  0 ) */
+     {{2, 0, 10},
+      {3, 0, 11},
+      {6, 0, 7},
+      {7, 0, 6},
+      {2, 1, 9},
+      {3, 1, 10},
+      {6, 1, 8},
+      {7, 1, 7},
+      {2, 4, 1},
+      {3, 4, 2},
+      {6, 4, 10},
+      {7, 4, 11},
+      {2, 5, 0},
+      {3, 5, 1},
+      {6, 5, 9},
+      {7, 5, 10}}},
+
+    {4, /* (  0 ,  1 , -1 ) */
+     {{2, 1, 11}, {6, 5, 11}, {2, 5, 2}, {6, 1, 6}}},
+
+    {16, /* (  0 ,  0 ,  1 ) */
+     {{1, 0, 12},
+      {3, 0, 11},
+      {5, 0, 5},
+      {7, 0, 2},
+      {1, 2, 9},
+      {3, 2, 12},
+      {5, 2, 8},
+      {7, 2, 5},
+      {1, 4, 3},
+      {3, 4, 6},
+      {5, 4, 12},
+      {7, 4, 11},
+      {1, 6, 0},
+      {3, 6, 3},
+      {5, 6, 9},
+      {7, 6, 12}}}};
+
 /**
  * @brief Get the size of the cell subtree.
  *
  * @param c The #cell.
  */
 int cell_getsize(struct cell *c) {
-
   /* Number of cells in this subtree. */
   int count = 1;
 
@@ -99,7 +186,6 @@ int cell_getsize(struct cell *c) {
  * @return The number of particles linked.
  */
 int cell_link_parts(struct cell *c, struct part *parts) {
-
 #ifdef SWIFT_DEBUG_CHECKS
   if (c->nodeID == engine_rank)
     error("Linking foreign particles in a local cell!");
@@ -132,7 +218,6 @@ int cell_link_parts(struct cell *c, struct part *parts) {
  * @return The number of particles linked.
  */
 int cell_link_gparts(struct cell *c, struct gpart *gparts) {
-
 #ifdef SWIFT_DEBUG_CHECKS
   if (c->nodeID == engine_rank)
     error("Linking foreign particles in a local cell!");
@@ -165,7 +250,6 @@ int cell_link_gparts(struct cell *c, struct gpart *gparts) {
  * @return The number of particles linked.
  */
 int cell_link_sparts(struct cell *c, struct spart *sparts) {
-
 #ifdef SWIFT_DEBUG_CHECKS
   if (c->nodeID == engine_rank)
     error("Linking foreign particles in a local cell!");
@@ -233,7 +317,6 @@ int cell_link_bparts(struct cell *c, struct bpart *bparts) {
  * @return The number of particles linked.
  */
 int cell_link_foreign_parts(struct cell *c, struct part *parts) {
-
 #ifdef WITH_MPI
 
 #ifdef SWIFT_DEBUG_CHECKS
@@ -243,7 +326,6 @@ int cell_link_foreign_parts(struct cell *c, struct part *parts) {
 
   /* Do we have a hydro task at this level? */
   if (c->mpi.hydro.recv_xv != NULL) {
-
     /* Recursively attach the parts */
     const int counts = cell_link_parts(c, parts);
 #ifdef SWIFT_DEBUG_CHECKS
@@ -282,7 +364,6 @@ int cell_link_foreign_parts(struct cell *c, struct part *parts) {
  * @return The number of particles linked.
  */
 int cell_link_foreign_gparts(struct cell *c, struct gpart *gparts) {
-
 #ifdef WITH_MPI
 
 #ifdef SWIFT_DEBUG_CHECKS
@@ -292,7 +373,6 @@ int cell_link_foreign_gparts(struct cell *c, struct gpart *gparts) {
 
   /* Do we have a hydro task at this level? */
   if (c->mpi.grav.recv != NULL) {
-
     /* Recursively attach the gparts */
     const int counts = cell_link_gparts(c, gparts);
 #ifdef SWIFT_DEBUG_CHECKS
@@ -329,7 +409,6 @@ int cell_link_foreign_gparts(struct cell *c, struct gpart *gparts) {
  * @return The number of particles linked.
  */
 int cell_count_parts_for_tasks(const struct cell *c) {
-
 #ifdef WITH_MPI
 
 #ifdef SWIFT_DEBUG_CHECKS
@@ -368,7 +447,6 @@ int cell_count_parts_for_tasks(const struct cell *c) {
  * @return The number of particles linked.
  */
 int cell_count_gparts_for_tasks(const struct cell *c) {
-
 #ifdef WITH_MPI
 
 #ifdef SWIFT_DEBUG_CHECKS
@@ -411,7 +489,6 @@ int cell_count_gparts_for_tasks(const struct cell *c) {
  */
 int cell_pack(struct cell *restrict c, struct pcell *restrict pc,
               const int with_gravity) {
-
 #ifdef WITH_MPI
 
   /* Start by packing the data of the current cell. */
@@ -480,7 +557,6 @@ int cell_pack(struct cell *restrict c, struct pcell *restrict pc,
  * @return The number of packed tags.
  */
 int cell_pack_tags(const struct cell *c, int *tags) {
-
 #ifdef WITH_MPI
 
   /* Start by packing the data of the current cell. */
@@ -518,7 +594,6 @@ int cell_pack_tags(const struct cell *c, int *tags) {
  */
 int cell_unpack(struct pcell *restrict pc, struct cell *restrict c,
                 struct space *restrict s, const int with_gravity) {
-
 #ifdef WITH_MPI
 
   /* Unpack the current pcell. */
@@ -545,7 +620,6 @@ int cell_unpack(struct pcell *restrict pc, struct cell *restrict c,
 
   /* Copy the Multipole related information */
   if (with_gravity) {
-
     struct gravity_tensors *mp = c->grav.multipole;
 
     mp->m_pole = pc->grav.m_pole;
@@ -613,7 +687,6 @@ int cell_unpack(struct pcell *restrict pc, struct cell *restrict c,
  * @return The number of tags created.
  */
 int cell_unpack_tags(const int *tags, struct cell *restrict c) {
-
 #ifdef WITH_MPI
 
   /* Unpack the current pcell. */
@@ -651,7 +724,6 @@ int cell_unpack_tags(const int *tags, struct cell *restrict c) {
  */
 int cell_pack_end_step_hydro(struct cell *restrict c,
                              struct pcell_step_hydro *restrict pcells) {
-
 #ifdef WITH_MPI
 
   /* Pack this cell's data. */
@@ -685,7 +757,6 @@ int cell_pack_end_step_hydro(struct cell *restrict c,
  */
 int cell_unpack_end_step_hydro(struct cell *restrict c,
                                struct pcell_step_hydro *restrict pcells) {
-
 #ifdef WITH_MPI
 
   /* Unpack this cell's data. */
@@ -719,7 +790,6 @@ int cell_unpack_end_step_hydro(struct cell *restrict c,
  */
 int cell_pack_end_step_grav(struct cell *restrict c,
                             struct pcell_step_grav *restrict pcells) {
-
 #ifdef WITH_MPI
 
   /* Pack this cell's data. */
@@ -752,7 +822,6 @@ int cell_pack_end_step_grav(struct cell *restrict c,
  */
 int cell_unpack_end_step_grav(struct cell *restrict c,
                               struct pcell_step_grav *restrict pcells) {
-
 #ifdef WITH_MPI
 
   /* Unpack this cell's data. */
@@ -785,7 +854,6 @@ int cell_unpack_end_step_grav(struct cell *restrict c,
  */
 int cell_pack_end_step_stars(struct cell *restrict c,
                              struct pcell_step_stars *restrict pcells) {
-
 #ifdef WITH_MPI
 
   /* Pack this cell's data. */
@@ -819,7 +887,6 @@ int cell_pack_end_step_stars(struct cell *restrict c,
  */
 int cell_unpack_end_step_stars(struct cell *restrict c,
                                struct pcell_step_stars *restrict pcells) {
-
 #ifdef WITH_MPI
 
   /* Unpack this cell's data. */
@@ -922,7 +989,6 @@ int cell_unpack_end_step_black_holes(
  */
 int cell_pack_multipoles(struct cell *restrict c,
                          struct gravity_tensors *restrict pcells) {
-
 #ifdef WITH_MPI
 
   /* Pack this cell's data. */
@@ -954,7 +1020,6 @@ int cell_pack_multipoles(struct cell *restrict c,
  */
 int cell_unpack_multipoles(struct cell *restrict c,
                            struct gravity_tensors *restrict pcells) {
-
 #ifdef WITH_MPI
 
   /* Unpack this cell's data. */
@@ -983,7 +1048,6 @@ int cell_unpack_multipoles(struct cell *restrict c,
  * @return 0 on success, 1 on failure
  */
 int cell_locktree(struct cell *c) {
-
   TIMER_TIC
 
   /* First of all, try to lock this cell. */
@@ -994,7 +1058,6 @@ int cell_locktree(struct cell *c) {
 
   /* Did somebody hold this cell in the meantime? */
   if (c->hydro.hold) {
-
     /* Unlock this cell. */
     if (lock_unlock(&c->hydro.lock) != 0) error("Failed to unlock cell.");
 
@@ -1006,7 +1069,6 @@ int cell_locktree(struct cell *c) {
   /* Climb up the tree and lock/hold/unlock. */
   struct cell *finger;
   for (finger = c->parent; finger != NULL; finger = finger->parent) {
-
     /* Lock this cell. */
     if (lock_trylock(&finger->hydro.lock) != 0) break;
 
@@ -1025,7 +1087,6 @@ int cell_locktree(struct cell *c) {
 
   /* Otherwise, we hit a snag. */
   else {
-
     /* Undo the holds up to finger. */
     for (struct cell *finger2 = c->parent; finger2 != finger;
          finger2 = finger2->parent)
@@ -1047,7 +1108,6 @@ int cell_locktree(struct cell *c) {
  * @return 0 on success, 1 on failure
  */
 int cell_glocktree(struct cell *c) {
-
   TIMER_TIC
 
   /* First of all, try to lock this cell. */
@@ -1058,7 +1118,6 @@ int cell_glocktree(struct cell *c) {
 
   /* Did somebody hold this cell in the meantime? */
   if (c->grav.phold) {
-
     /* Unlock this cell. */
     if (lock_unlock(&c->grav.plock) != 0) error("Failed to unlock cell.");
 
@@ -1070,7 +1129,6 @@ int cell_glocktree(struct cell *c) {
   /* Climb up the tree and lock/hold/unlock. */
   struct cell *finger;
   for (finger = c->parent; finger != NULL; finger = finger->parent) {
-
     /* Lock this cell. */
     if (lock_trylock(&finger->grav.plock) != 0) break;
 
@@ -1089,7 +1147,6 @@ int cell_glocktree(struct cell *c) {
 
   /* Otherwise, we hit a snag. */
   else {
-
     /* Undo the holds up to finger. */
     for (struct cell *finger2 = c->parent; finger2 != finger;
          finger2 = finger2->parent)
@@ -1111,7 +1168,6 @@ int cell_glocktree(struct cell *c) {
  * @return 0 on success, 1 on failure
  */
 int cell_mlocktree(struct cell *c) {
-
   TIMER_TIC
 
   /* First of all, try to lock this cell. */
@@ -1122,7 +1178,6 @@ int cell_mlocktree(struct cell *c) {
 
   /* Did somebody hold this cell in the meantime? */
   if (c->grav.mhold) {
-
     /* Unlock this cell. */
     if (lock_unlock(&c->grav.mlock) != 0) error("Failed to unlock cell.");
 
@@ -1134,7 +1189,6 @@ int cell_mlocktree(struct cell *c) {
   /* Climb up the tree and lock/hold/unlock. */
   struct cell *finger;
   for (finger = c->parent; finger != NULL; finger = finger->parent) {
-
     /* Lock this cell. */
     if (lock_trylock(&finger->grav.mlock) != 0) break;
 
@@ -1153,7 +1207,6 @@ int cell_mlocktree(struct cell *c) {
 
   /* Otherwise, we hit a snag. */
   else {
-
     /* Undo the holds up to finger. */
     for (struct cell *finger2 = c->parent; finger2 != finger;
          finger2 = finger2->parent)
@@ -1175,7 +1228,6 @@ int cell_mlocktree(struct cell *c) {
  * @return 0 on success, 1 on failure
  */
 int cell_slocktree(struct cell *c) {
-
   TIMER_TIC
 
   /* First of all, try to lock this cell. */
@@ -1186,7 +1238,6 @@ int cell_slocktree(struct cell *c) {
 
   /* Did somebody hold this cell in the meantime? */
   if (c->stars.hold) {
-
     /* Unlock this cell. */
     if (lock_unlock(&c->stars.lock) != 0) error("Failed to unlock cell.");
 
@@ -1198,7 +1249,6 @@ int cell_slocktree(struct cell *c) {
   /* Climb up the tree and lock/hold/unlock. */
   struct cell *finger;
   for (finger = c->parent; finger != NULL; finger = finger->parent) {
-
     /* Lock this cell. */
     if (lock_trylock(&finger->stars.lock) != 0) break;
 
@@ -1217,7 +1267,6 @@ int cell_slocktree(struct cell *c) {
 
   /* Otherwise, we hit a snag. */
   else {
-
     /* Undo the holds up to finger. */
     for (struct cell *finger2 = c->parent; finger2 != finger;
          finger2 = finger2->parent)
@@ -1238,7 +1287,6 @@ int cell_slocktree(struct cell *c) {
  * @param c The #cell.
  */
 void cell_unlocktree(struct cell *c) {
-
   TIMER_TIC
 
   /* First of all, try to unlock this cell. */
@@ -1257,7 +1305,6 @@ void cell_unlocktree(struct cell *c) {
  * @param c The #cell.
  */
 void cell_gunlocktree(struct cell *c) {
-
   TIMER_TIC
 
   /* First of all, try to unlock this cell. */
@@ -1276,7 +1323,6 @@ void cell_gunlocktree(struct cell *c) {
  * @param c The #cell.
  */
 void cell_munlocktree(struct cell *c) {
-
   TIMER_TIC
 
   /* First of all, try to unlock this cell. */
@@ -1295,7 +1341,6 @@ void cell_munlocktree(struct cell *c) {
  * @param c The #cell.
  */
 void cell_sunlocktree(struct cell *c) {
-
   TIMER_TIC
 
   /* First of all, try to unlock this cell. */
@@ -1332,7 +1377,6 @@ void cell_split(struct cell *c, ptrdiff_t parts_offset, ptrdiff_t sparts_offset,
                 ptrdiff_t bparts_offset, struct cell_buff *buff,
                 struct cell_buff *sbuff, struct cell_buff *bbuff,
                 struct cell_buff *gbuff) {
-
   const int count = c->hydro.count, gcount = c->grav.count,
             scount = c->stars.count, bcount = c->black_holes.count;
   struct part *parts = c->hydro.parts;
@@ -1677,7 +1721,6 @@ void cell_split(struct cell *c, ptrdiff_t parts_offset, ptrdiff_t sparts_offset,
  * @param treated Has the cell already been sanitized at this level ?
  */
 void cell_sanitize(struct cell *c, int treated) {
-
   const int count = c->hydro.count;
   const int scount = c->stars.count;
   struct part *parts = c->hydro.parts;
@@ -1687,7 +1730,6 @@ void cell_sanitize(struct cell *c, int treated) {
 
   /* Treat cells will <1000 particles */
   if (count < 1000 && !treated) {
-
     /* Get an upper bound on h */
     const float upper_h_max = c->dmin / (1.2f * kernel_gamma);
 
@@ -1704,10 +1746,8 @@ void cell_sanitize(struct cell *c, int treated) {
 
   /* Recurse and gather the new h_max values */
   if (c->split) {
-
     for (int k = 0; k < 8; ++k) {
       if (c->progeny[k] != NULL) {
-
         /* Recurse */
         cell_sanitize(c->progeny[k], (count < 1000));
 
@@ -1717,7 +1757,6 @@ void cell_sanitize(struct cell *c, int treated) {
       }
     }
   } else {
-
     /* Get the new value of h_max */
     for (int i = 0; i < count; ++i) h_max = max(h_max, parts[i].h);
     for (int i = 0; i < scount; ++i)
@@ -1756,7 +1795,6 @@ void cell_clean_links(struct cell *c, void *data) {
  * @param data The current time on the integer time-line
  */
 void cell_check_part_drift_point(struct cell *c, void *data) {
-
 #ifdef SWIFT_DEBUG_CHECKS
 
   const integertime_t ti_drift = *(integertime_t *)data;
@@ -1791,7 +1829,6 @@ void cell_check_part_drift_point(struct cell *c, void *data) {
  * @param data The current time on the integer time-line
  */
 void cell_check_gpart_drift_point(struct cell *c, void *data) {
-
 #ifdef SWIFT_DEBUG_CHECKS
 
   const integertime_t ti_drift = *(integertime_t *)data;
@@ -1828,7 +1865,6 @@ void cell_check_gpart_drift_point(struct cell *c, void *data) {
  * @param data The current time on the integer time-line
  */
 void cell_check_spart_drift_point(struct cell *c, void *data) {
-
 #ifdef SWIFT_DEBUG_CHECKS
 
   const integertime_t ti_drift = *(integertime_t *)data;
@@ -1864,7 +1900,6 @@ void cell_check_spart_drift_point(struct cell *c, void *data) {
  * @param data The current time on the integer time-line
  */
 void cell_check_multipole_drift_point(struct cell *c, void *data) {
-
 #ifdef SWIFT_DEBUG_CHECKS
 
   const integertime_t ti_drift = *(integertime_t *)data;
@@ -1895,7 +1930,6 @@ void cell_check_multipole_drift_point(struct cell *c, void *data) {
  * @param c The #cell to reset.
  */
 void cell_reset_task_counters(struct cell *c) {
-
 #ifdef SWIFT_DEBUG_CHECKS
   for (int t = 0; t < task_type_count; ++t) c->tasks_executed[t] = 0;
   for (int t = 0; t < task_subtype_count; ++t) c->subtasks_executed[t] = 0;
@@ -1913,12 +1947,10 @@ void cell_reset_task_counters(struct cell *c) {
  * @param ti_current The current integer time.
  */
 void cell_make_multipoles(struct cell *c, integertime_t ti_current) {
-
   /* Reset everything */
   gravity_reset(c->grav.multipole);
 
   if (c->split) {
-
     /* Start by recursing */
     for (int k = 0; k < 8; ++k) {
       if (c->progeny[k] != NULL)
@@ -1982,7 +2014,6 @@ void cell_make_multipoles(struct cell *c, integertime_t ti_current) {
     c->grav.multipole->r_max = min(r_max, sqrt(dx * dx + dy * dy + dz * dz));
 
   } else {
-
     if (c->grav.count > 0) {
       gravity_P2M(c->grav.multipole, c->grav.parts, c->grav.count);
       const double dx =
@@ -2025,11 +2056,9 @@ void cell_make_multipoles(struct cell *c, integertime_t ti_current) {
  * @param c The #cell to recursively search and verify.
  */
 void cell_check_foreign_multipole(const struct cell *c) {
-
 #ifdef SWIFT_DEBUG_CHECKS
 
   if (c->split) {
-
     double M_000 = 0.;
     long long num_gpart = 0;
 
@@ -2037,7 +2066,6 @@ void cell_check_foreign_multipole(const struct cell *c) {
       const struct cell *cp = c->progeny[k];
 
       if (cp != NULL) {
-
         /* Check the mass */
         M_000 += cp->grav.multipole->m_pole.M_000;
 
@@ -2065,7 +2093,6 @@ void cell_check_foreign_multipole(const struct cell *c) {
  * @param c Cell to act upon
  */
 void cell_check_multipole(struct cell *c) {
-
 #ifdef SWIFT_DEBUG_CHECKS
   struct gravity_tensors ma;
   const double tolerance = 1e-3; /* Relative */
@@ -2076,7 +2103,6 @@ void cell_check_multipole(struct cell *c) {
       if (c->progeny[k] != NULL) cell_check_multipole(c->progeny[k]);
 
   if (c->grav.count > 0) {
-
     /* Brute-force calculation */
     gravity_P2M(&ma, c->grav.parts, c->grav.count);
 
@@ -2112,7 +2138,6 @@ void cell_check_multipole(struct cell *c) {
  * @param c The #cell.
  */
 void cell_clean(struct cell *c) {
-
   /* Hydro */
   cell_free_hydro_sorts(c);
 
@@ -2152,7 +2177,6 @@ void cell_clear_limiter_flags(struct cell *c, void *data) {
  * @param s The #scheduler.
  */
 void cell_activate_super_spart_drifts(struct cell *c, struct scheduler *s) {
-
   if (c == c->hydro.super) {
     cell_activate_drift_spart(c, s);
   } else {
@@ -2174,7 +2198,6 @@ void cell_activate_super_spart_drifts(struct cell *c, struct scheduler *s) {
  * @brief Activate the #part drifts on the given cell.
  */
 void cell_activate_drift_part(struct cell *c, struct scheduler *s) {
-
   /* If this cell is already marked for drift, quit early. */
   if (c->hydro.do_drift) return;
 
@@ -2193,7 +2216,6 @@ void cell_activate_drift_part(struct cell *c, struct scheduler *s) {
     for (struct cell *parent = c->parent;
          parent != NULL && !parent->hydro.do_sub_drift;
          parent = parent->parent) {
-
       /* Mark this cell for drifting */
       parent->hydro.do_sub_drift = 1;
 
@@ -2213,7 +2235,6 @@ void cell_activate_drift_part(struct cell *c, struct scheduler *s) {
  * @brief Activate the #gpart drifts on the given cell.
  */
 void cell_activate_drift_gpart(struct cell *c, struct scheduler *s) {
-
   /* If this cell is already marked for drift, quit early. */
   if (c->grav.do_drift) return;
 
@@ -2256,7 +2277,6 @@ void cell_activate_drift_gpart(struct cell *c, struct scheduler *s) {
  * @brief Activate the #spart drifts on the given cell.
  */
 void cell_activate_drift_spart(struct cell *c, struct scheduler *s) {
-
   /* If this cell is already marked for drift, quit early. */
   if (c->stars.do_drift) return;
 
@@ -2275,7 +2295,6 @@ void cell_activate_drift_spart(struct cell *c, struct scheduler *s) {
     for (struct cell *parent = c->parent;
          parent != NULL && !parent->stars.do_sub_drift;
          parent = parent->parent) {
-
       /* Mark this cell for drifting */
       parent->stars.do_sub_drift = 1;
 
@@ -2295,7 +2314,6 @@ void cell_activate_drift_spart(struct cell *c, struct scheduler *s) {
  * @brief Activate the drifts on the given cell.
  */
 void cell_activate_limiter(struct cell *c, struct scheduler *s) {
-
   /* If this cell is already marked for limiting, quit early. */
   if (c->hydro.do_limiter) return;
 
@@ -2314,7 +2332,6 @@ void cell_activate_limiter(struct cell *c, struct scheduler *s) {
     for (struct cell *parent = c->parent;
          parent != NULL && !parent->hydro.do_sub_limiter;
          parent = parent->parent) {
-
       /* Mark this cell for limiting */
       parent->hydro.do_sub_limiter = 1;
 
@@ -2334,7 +2351,6 @@ void cell_activate_limiter(struct cell *c, struct scheduler *s) {
  * @brief Activate the sorts up a cell hierarchy.
  */
 void cell_activate_hydro_sorts_up(struct cell *c, struct scheduler *s) {
-
   if (c == c->hydro.super) {
 #ifdef SWIFT_DEBUG_CHECKS
     if (c->hydro.sorts == NULL)
@@ -2343,7 +2359,6 @@ void cell_activate_hydro_sorts_up(struct cell *c, struct scheduler *s) {
     scheduler_activate(s, c->hydro.sorts);
     if (c->nodeID == engine_rank) cell_activate_drift_part(c, s);
   } else {
-
     for (struct cell *parent = c->parent;
          parent != NULL && !parent->hydro.do_sub_sort;
          parent = parent->parent) {
@@ -2365,10 +2380,8 @@ void cell_activate_hydro_sorts_up(struct cell *c, struct scheduler *s) {
  * @brief Activate the sorts on a given cell, if needed.
  */
 void cell_activate_hydro_sorts(struct cell *c, int sid, struct scheduler *s) {
-
   /* Do we need to re-sort? */
   if (c->hydro.dx_max_sort > space_maxreldx * c->dmin) {
-
     /* Climb up the tree to active the sorts in that direction */
     for (struct cell *finger = c; finger != NULL; finger = finger->parent) {
       if (finger->hydro.requires_sorts) {
@@ -2381,7 +2394,6 @@ void cell_activate_hydro_sorts(struct cell *c, int sid, struct scheduler *s) {
 
   /* Has this cell been sorted at all for the given sid? */
   if (!(c->hydro.sorted & (1 << sid)) || c->nodeID != engine_rank) {
-
     atomic_or(&c->hydro.do_sort, (1 << sid));
     cell_activate_hydro_sorts_up(c, s);
   }
@@ -2391,7 +2403,6 @@ void cell_activate_hydro_sorts(struct cell *c, int sid, struct scheduler *s) {
  * @brief Activate the sorts up a cell hierarchy.
  */
 void cell_activate_stars_sorts_up(struct cell *c, struct scheduler *s) {
-
   if (c == c->hydro.super) {
 #ifdef SWIFT_DEBUG_CHECKS
     if (c->stars.sorts == NULL)
@@ -2403,7 +2414,6 @@ void cell_activate_stars_sorts_up(struct cell *c, struct scheduler *s) {
       cell_activate_drift_spart(c, s);
     }
   } else {
-
     for (struct cell *parent = c->parent;
          parent != NULL && !parent->stars.do_sub_sort;
          parent = parent->parent) {
@@ -2425,10 +2435,8 @@ void cell_activate_stars_sorts_up(struct cell *c, struct scheduler *s) {
  * @brief Activate the sorts on a given cell, if needed.
  */
 void cell_activate_stars_sorts(struct cell *c, int sid, struct scheduler *s) {
-
   /* Do we need to re-sort? */
   if (c->stars.dx_max_sort > space_maxreldx * c->dmin) {
-
     /* Climb up the tree to active the sorts in that direction */
     for (struct cell *finger = c; finger != NULL; finger = finger->parent) {
       if (finger->stars.requires_sorts) {
@@ -2441,7 +2449,6 @@ void cell_activate_stars_sorts(struct cell *c, int sid, struct scheduler *s) {
 
   /* Has this cell been sorted at all for the given sid? */
   if (!(c->stars.sorted & (1 << sid)) || c->nodeID != engine_rank) {
-
     atomic_or(&c->stars.do_sort, (1 << sid));
     cell_activate_stars_sorts_up(c, s);
   }
@@ -2471,13 +2478,11 @@ void cell_activate_subcell_hydro_tasks(struct cell *ci, struct cell *cj,
 
   /* Self interaction? */
   if (cj == NULL) {
-
     /* Do anything? */
     if (ci->hydro.count == 0 || !cell_is_active_hydro(ci, e)) return;
 
     /* Recurse? */
     if (cell_can_recurse_in_self_hydro_task(ci)) {
-
       /* Loop over all progenies and pairs of progenies */
       for (int j = 0; j < 8; j++) {
         if (ci->progeny[j] != NULL) {
@@ -2489,7 +2494,6 @@ void cell_activate_subcell_hydro_tasks(struct cell *ci, struct cell *cj,
         }
       }
     } else {
-
       /* We have reached the bottom of the tree: activate drift */
       cell_activate_drift_part(ci, s);
       if (with_limiter) cell_activate_limiter(ci, s);
@@ -2498,7 +2502,6 @@ void cell_activate_subcell_hydro_tasks(struct cell *ci, struct cell *cj,
 
   /* Otherwise, pair interation */
   else {
-
     /* Should we even bother? */
     if (!cell_is_active_hydro(ci, e) && !cell_is_active_hydro(cj, e)) return;
     if (ci->hydro.count == 0 || cj->hydro.count == 0) return;
@@ -2510,284 +2513,18 @@ void cell_activate_subcell_hydro_tasks(struct cell *ci, struct cell *cj,
     /* recurse? */
     if (cell_can_recurse_in_pair_hydro_task(ci) &&
         cell_can_recurse_in_pair_hydro_task(cj)) {
-
-      /* Different types of flags. */
-      switch (sid) {
-
-        /* Regular sub-cell interactions of a single cell. */
-        case 0: /* (  1 ,  1 ,  1 ) */
-          if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[0],
-                                              s);
-          break;
-
-        case 1: /* (  1 ,  1 ,  0 ) */
-          if (ci->progeny[6] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[0],
-                                              s);
-          if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[1],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[0],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[1],
-                                              s);
-          break;
-
-        case 2: /* (  1 ,  1 , -1 ) */
-          if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[1],
-                                              s);
-          break;
-
-        case 3: /* (  1 ,  0 ,  1 ) */
-          if (ci->progeny[5] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[5], cj->progeny[0],
-                                              s);
-          if (ci->progeny[5] != NULL && cj->progeny[2] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[5], cj->progeny[2],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[0],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[2] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[2],
-                                              s);
-          break;
-
-        case 4: /* (  1 ,  0 ,  0 ) */
-          if (ci->progeny[4] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[4], cj->progeny[0],
-                                              s);
-          if (ci->progeny[4] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[4], cj->progeny[1],
-                                              s);
-          if (ci->progeny[4] != NULL && cj->progeny[2] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[4], cj->progeny[2],
-                                              s);
-          if (ci->progeny[4] != NULL && cj->progeny[3] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[4], cj->progeny[3],
-                                              s);
-          if (ci->progeny[5] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[5], cj->progeny[0],
-                                              s);
-          if (ci->progeny[5] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[5], cj->progeny[1],
-                                              s);
-          if (ci->progeny[5] != NULL && cj->progeny[2] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[5], cj->progeny[2],
-                                              s);
-          if (ci->progeny[5] != NULL && cj->progeny[3] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[5], cj->progeny[3],
-                                              s);
-          if (ci->progeny[6] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[0],
-                                              s);
-          if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[1],
-                                              s);
-          if (ci->progeny[6] != NULL && cj->progeny[2] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[2],
-                                              s);
-          if (ci->progeny[6] != NULL && cj->progeny[3] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[3],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[0],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[1],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[2] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[2],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[3] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[3],
-                                              s);
-          break;
-
-        case 5: /* (  1 ,  0 , -1 ) */
-          if (ci->progeny[4] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[4], cj->progeny[1],
-                                              s);
-          if (ci->progeny[4] != NULL && cj->progeny[3] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[4], cj->progeny[3],
-                                              s);
-          if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[1],
-                                              s);
-          if (ci->progeny[6] != NULL && cj->progeny[3] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[3],
-                                              s);
-          break;
-
-        case 6: /* (  1 , -1 ,  1 ) */
-          if (ci->progeny[5] != NULL && cj->progeny[2] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[5], cj->progeny[2],
-                                              s);
-          break;
-
-        case 7: /* (  1 , -1 ,  0 ) */
-          if (ci->progeny[4] != NULL && cj->progeny[2] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[4], cj->progeny[2],
-                                              s);
-          if (ci->progeny[4] != NULL && cj->progeny[3] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[4], cj->progeny[3],
-                                              s);
-          if (ci->progeny[5] != NULL && cj->progeny[2] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[5], cj->progeny[2],
-                                              s);
-          if (ci->progeny[5] != NULL && cj->progeny[3] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[5], cj->progeny[3],
-                                              s);
-          break;
-
-        case 8: /* (  1 , -1 , -1 ) */
-          if (ci->progeny[4] != NULL && cj->progeny[3] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[4], cj->progeny[3],
-                                              s);
-          break;
-
-        case 9: /* (  0 ,  1 ,  1 ) */
-          if (ci->progeny[3] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[3], cj->progeny[0],
-                                              s);
-          if (ci->progeny[3] != NULL && cj->progeny[4] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[3], cj->progeny[4],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[0],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[4] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[4],
-                                              s);
-          break;
-
-        case 10: /* (  0 ,  1 ,  0 ) */
-          if (ci->progeny[2] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[2], cj->progeny[0],
-                                              s);
-          if (ci->progeny[2] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[2], cj->progeny[1],
-                                              s);
-          if (ci->progeny[2] != NULL && cj->progeny[4] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[2], cj->progeny[4],
-                                              s);
-          if (ci->progeny[2] != NULL && cj->progeny[5] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[2], cj->progeny[5],
-                                              s);
-          if (ci->progeny[3] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[3], cj->progeny[0],
-                                              s);
-          if (ci->progeny[3] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[3], cj->progeny[1],
-                                              s);
-          if (ci->progeny[3] != NULL && cj->progeny[4] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[3], cj->progeny[4],
-                                              s);
-          if (ci->progeny[3] != NULL && cj->progeny[5] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[3], cj->progeny[5],
-                                              s);
-          if (ci->progeny[6] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[0],
-                                              s);
-          if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[1],
-                                              s);
-          if (ci->progeny[6] != NULL && cj->progeny[4] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[4],
-                                              s);
-          if (ci->progeny[6] != NULL && cj->progeny[5] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[5],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[0],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[1],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[4] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[4],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[5] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[5],
-                                              s);
-          break;
-
-        case 11: /* (  0 ,  1 , -1 ) */
-          if (ci->progeny[2] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[2], cj->progeny[1],
-                                              s);
-          if (ci->progeny[2] != NULL && cj->progeny[5] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[2], cj->progeny[5],
-                                              s);
-          if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[1],
-                                              s);
-          if (ci->progeny[6] != NULL && cj->progeny[5] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[5],
-                                              s);
-          break;
-
-        case 12: /* (  0 ,  0 ,  1 ) */
-          if (ci->progeny[1] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[1], cj->progeny[0],
-                                              s);
-          if (ci->progeny[1] != NULL && cj->progeny[2] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[1], cj->progeny[2],
-                                              s);
-          if (ci->progeny[1] != NULL && cj->progeny[4] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[1], cj->progeny[4],
-                                              s);
-          if (ci->progeny[1] != NULL && cj->progeny[6] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[1], cj->progeny[6],
-                                              s);
-          if (ci->progeny[3] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[3], cj->progeny[0],
-                                              s);
-          if (ci->progeny[3] != NULL && cj->progeny[2] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[3], cj->progeny[2],
-                                              s);
-          if (ci->progeny[3] != NULL && cj->progeny[4] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[3], cj->progeny[4],
-                                              s);
-          if (ci->progeny[3] != NULL && cj->progeny[6] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[3], cj->progeny[6],
-                                              s);
-          if (ci->progeny[5] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[5], cj->progeny[0],
-                                              s);
-          if (ci->progeny[5] != NULL && cj->progeny[2] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[5], cj->progeny[2],
-                                              s);
-          if (ci->progeny[5] != NULL && cj->progeny[4] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[5], cj->progeny[4],
-                                              s);
-          if (ci->progeny[5] != NULL && cj->progeny[6] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[5], cj->progeny[6],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[0],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[2] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[2],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[4] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[4],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[6] != NULL)
-            cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[6],
-                                              s);
-          break;
+      struct cell_split_pair *csp = &cell_split_pairs[sid];
+      for (int k = 0; k < csp->count; k++) {
+        const int pid = csp->pairs[k].pid;
+        const int pjd = csp->pairs[k].pjd;
+        if (ci->progeny[pid] != NULL && cj->progeny[pjd] != NULL)
+          cell_activate_subcell_hydro_tasks(ci->progeny[pid], cj->progeny[pjd],
+                                            s);
       }
-
     }
 
     /* Otherwise, activate the sorts and drifts. */
     else if (cell_is_active_hydro(ci, e) || cell_is_active_hydro(cj, e)) {
-
       /* We are going to interact this pair, so store some values. */
       atomic_or(&ci->hydro.requires_sorts, 1 << sid);
       atomic_or(&cj->hydro.requires_sorts, 1 << sid);
@@ -2838,7 +2575,6 @@ void cell_activate_subcell_stars_tasks(struct cell *ci, struct cell *cj,
 
   /* Self interaction? */
   if (cj == NULL) {
-
     /* Do anything? */
     if (!cell_is_active_stars(ci, e) || ci->hydro.count == 0 ||
         ci->stars.count == 0)
@@ -2846,7 +2582,6 @@ void cell_activate_subcell_stars_tasks(struct cell *ci, struct cell *cj,
 
     /* Recurse? */
     if (cell_can_recurse_in_self_stars_task(ci)) {
-
       /* Loop over all progenies and pairs of progenies */
       for (int j = 0; j < 8; j++) {
         if (ci->progeny[j] != NULL) {
@@ -2858,7 +2593,6 @@ void cell_activate_subcell_stars_tasks(struct cell *ci, struct cell *cj,
         }
       }
     } else {
-
       /* We have reached the bottom of the tree: activate drift */
       cell_activate_drift_spart(ci, s);
       cell_activate_drift_part(ci, s);
@@ -2867,7 +2601,6 @@ void cell_activate_subcell_stars_tasks(struct cell *ci, struct cell *cj,
 
   /* Otherwise, pair interation */
   else {
-
     /* Should we even bother? */
     if (!cell_is_active_stars(ci, e) && !cell_is_active_stars(cj, e)) return;
 
@@ -2878,284 +2611,18 @@ void cell_activate_subcell_stars_tasks(struct cell *ci, struct cell *cj,
     /* recurse? */
     if (cell_can_recurse_in_pair_stars_task(ci, cj) &&
         cell_can_recurse_in_pair_stars_task(cj, ci)) {
-
-      /* Different types of flags. */
-      switch (sid) {
-
-        /* Regular sub-cell interactions of a single cell. */
-        case 0: /* (  1 ,  1 ,  1 ) */
-          if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[7], cj->progeny[0],
-                                              s);
-          break;
-
-        case 1: /* (  1 ,  1 ,  0 ) */
-          if (ci->progeny[6] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[6], cj->progeny[0],
-                                              s);
-          if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[6], cj->progeny[1],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[7], cj->progeny[0],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[7], cj->progeny[1],
-                                              s);
-          break;
-
-        case 2: /* (  1 ,  1 , -1 ) */
-          if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[6], cj->progeny[1],
-                                              s);
-          break;
-
-        case 3: /* (  1 ,  0 ,  1 ) */
-          if (ci->progeny[5] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[5], cj->progeny[0],
-                                              s);
-          if (ci->progeny[5] != NULL && cj->progeny[2] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[5], cj->progeny[2],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[7], cj->progeny[0],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[2] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[7], cj->progeny[2],
-                                              s);
-          break;
-
-        case 4: /* (  1 ,  0 ,  0 ) */
-          if (ci->progeny[4] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[4], cj->progeny[0],
-                                              s);
-          if (ci->progeny[4] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[4], cj->progeny[1],
-                                              s);
-          if (ci->progeny[4] != NULL && cj->progeny[2] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[4], cj->progeny[2],
-                                              s);
-          if (ci->progeny[4] != NULL && cj->progeny[3] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[4], cj->progeny[3],
-                                              s);
-          if (ci->progeny[5] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[5], cj->progeny[0],
-                                              s);
-          if (ci->progeny[5] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[5], cj->progeny[1],
-                                              s);
-          if (ci->progeny[5] != NULL && cj->progeny[2] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[5], cj->progeny[2],
-                                              s);
-          if (ci->progeny[5] != NULL && cj->progeny[3] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[5], cj->progeny[3],
-                                              s);
-          if (ci->progeny[6] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[6], cj->progeny[0],
-                                              s);
-          if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[6], cj->progeny[1],
-                                              s);
-          if (ci->progeny[6] != NULL && cj->progeny[2] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[6], cj->progeny[2],
-                                              s);
-          if (ci->progeny[6] != NULL && cj->progeny[3] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[6], cj->progeny[3],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[7], cj->progeny[0],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[7], cj->progeny[1],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[2] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[7], cj->progeny[2],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[3] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[7], cj->progeny[3],
-                                              s);
-          break;
-
-        case 5: /* (  1 ,  0 , -1 ) */
-          if (ci->progeny[4] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[4], cj->progeny[1],
-                                              s);
-          if (ci->progeny[4] != NULL && cj->progeny[3] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[4], cj->progeny[3],
-                                              s);
-          if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[6], cj->progeny[1],
-                                              s);
-          if (ci->progeny[6] != NULL && cj->progeny[3] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[6], cj->progeny[3],
-                                              s);
-          break;
-
-        case 6: /* (  1 , -1 ,  1 ) */
-          if (ci->progeny[5] != NULL && cj->progeny[2] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[5], cj->progeny[2],
-                                              s);
-          break;
-
-        case 7: /* (  1 , -1 ,  0 ) */
-          if (ci->progeny[4] != NULL && cj->progeny[2] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[4], cj->progeny[2],
-                                              s);
-          if (ci->progeny[4] != NULL && cj->progeny[3] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[4], cj->progeny[3],
-                                              s);
-          if (ci->progeny[5] != NULL && cj->progeny[2] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[5], cj->progeny[2],
-                                              s);
-          if (ci->progeny[5] != NULL && cj->progeny[3] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[5], cj->progeny[3],
-                                              s);
-          break;
-
-        case 8: /* (  1 , -1 , -1 ) */
-          if (ci->progeny[4] != NULL && cj->progeny[3] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[4], cj->progeny[3],
-                                              s);
-          break;
-
-        case 9: /* (  0 ,  1 ,  1 ) */
-          if (ci->progeny[3] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[3], cj->progeny[0],
-                                              s);
-          if (ci->progeny[3] != NULL && cj->progeny[4] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[3], cj->progeny[4],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[7], cj->progeny[0],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[4] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[7], cj->progeny[4],
-                                              s);
-          break;
-
-        case 10: /* (  0 ,  1 ,  0 ) */
-          if (ci->progeny[2] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[2], cj->progeny[0],
-                                              s);
-          if (ci->progeny[2] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[2], cj->progeny[1],
-                                              s);
-          if (ci->progeny[2] != NULL && cj->progeny[4] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[2], cj->progeny[4],
-                                              s);
-          if (ci->progeny[2] != NULL && cj->progeny[5] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[2], cj->progeny[5],
-                                              s);
-          if (ci->progeny[3] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[3], cj->progeny[0],
-                                              s);
-          if (ci->progeny[3] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[3], cj->progeny[1],
-                                              s);
-          if (ci->progeny[3] != NULL && cj->progeny[4] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[3], cj->progeny[4],
-                                              s);
-          if (ci->progeny[3] != NULL && cj->progeny[5] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[3], cj->progeny[5],
-                                              s);
-          if (ci->progeny[6] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[6], cj->progeny[0],
-                                              s);
-          if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[6], cj->progeny[1],
-                                              s);
-          if (ci->progeny[6] != NULL && cj->progeny[4] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[6], cj->progeny[4],
-                                              s);
-          if (ci->progeny[6] != NULL && cj->progeny[5] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[6], cj->progeny[5],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[7], cj->progeny[0],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[7], cj->progeny[1],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[4] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[7], cj->progeny[4],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[5] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[7], cj->progeny[5],
-                                              s);
-          break;
-
-        case 11: /* (  0 ,  1 , -1 ) */
-          if (ci->progeny[2] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[2], cj->progeny[1],
-                                              s);
-          if (ci->progeny[2] != NULL && cj->progeny[5] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[2], cj->progeny[5],
-                                              s);
-          if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[6], cj->progeny[1],
-                                              s);
-          if (ci->progeny[6] != NULL && cj->progeny[5] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[6], cj->progeny[5],
-                                              s);
-          break;
-
-        case 12: /* (  0 ,  0 ,  1 ) */
-          if (ci->progeny[1] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[1], cj->progeny[0],
-                                              s);
-          if (ci->progeny[1] != NULL && cj->progeny[2] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[1], cj->progeny[2],
-                                              s);
-          if (ci->progeny[1] != NULL && cj->progeny[4] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[1], cj->progeny[4],
-                                              s);
-          if (ci->progeny[1] != NULL && cj->progeny[6] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[1], cj->progeny[6],
-                                              s);
-          if (ci->progeny[3] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[3], cj->progeny[0],
-                                              s);
-          if (ci->progeny[3] != NULL && cj->progeny[2] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[3], cj->progeny[2],
-                                              s);
-          if (ci->progeny[3] != NULL && cj->progeny[4] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[3], cj->progeny[4],
-                                              s);
-          if (ci->progeny[3] != NULL && cj->progeny[6] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[3], cj->progeny[6],
-                                              s);
-          if (ci->progeny[5] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[5], cj->progeny[0],
-                                              s);
-          if (ci->progeny[5] != NULL && cj->progeny[2] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[5], cj->progeny[2],
-                                              s);
-          if (ci->progeny[5] != NULL && cj->progeny[4] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[5], cj->progeny[4],
-                                              s);
-          if (ci->progeny[5] != NULL && cj->progeny[6] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[5], cj->progeny[6],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[7], cj->progeny[0],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[2] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[7], cj->progeny[2],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[4] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[7], cj->progeny[4],
-                                              s);
-          if (ci->progeny[7] != NULL && cj->progeny[6] != NULL)
-            cell_activate_subcell_stars_tasks(ci->progeny[7], cj->progeny[6],
-                                              s);
-          break;
+      struct cell_split_pair *csp = &cell_split_pairs[sid];
+      for (int k = 0; k < csp->count; k++) {
+        const int pid = csp->pairs[k].pid;
+        const int pjd = csp->pairs[k].pjd;
+        if (ci->progeny[pid] != NULL && cj->progeny[pjd] != NULL)
+          cell_activate_subcell_stars_tasks(ci->progeny[pid], cj->progeny[pjd],
+                                            s);
       }
-
     }
 
     /* Otherwise, activate the sorts and drifts. */
     else {
-
       if (cell_is_active_stars(ci, e)) {
         /* We are going to interact this pair, so store some values. */
         atomic_or(&cj->hydro.requires_sorts, 1 << sid);
@@ -3209,13 +2676,11 @@ void cell_activate_subcell_grav_tasks(struct cell *ci, struct cell *cj,
 
   /* Self interaction? */
   if (cj == NULL) {
-
     /* Do anything? */
     if (ci->grav.count == 0 || !cell_is_active_gravity(ci, e)) return;
 
     /* Recurse? */
     if (ci->split) {
-
       /* Loop over all progenies and pairs of progenies */
       for (int j = 0; j < 8; j++) {
         if (ci->progeny[j] != NULL) {
@@ -3227,7 +2692,6 @@ void cell_activate_subcell_grav_tasks(struct cell *ci, struct cell *cj,
         }
       }
     } else {
-
       /* We have reached the bottom of the tree: activate gpart drift */
       cell_activate_drift_gpart(ci, s);
     }
@@ -3235,7 +2699,6 @@ void cell_activate_subcell_grav_tasks(struct cell *ci, struct cell *cj,
 
   /* Pair interaction */
   else {
-
     /* Anything to do here? */
     if (!cell_is_active_gravity(ci, e) && !cell_is_active_gravity(cj, e))
       return;
@@ -3253,13 +2716,11 @@ void cell_activate_subcell_grav_tasks(struct cell *ci, struct cell *cj,
 
     /* Can we use multipoles ? */
     if (cell_can_use_pair_mm(ci, cj, e, sp)) {
-
       /* Ok, no need to drift anything */
       return;
     }
     /* Otherwise, activate the gpart drifts if we are at the bottom. */
     else if (!ci->split && !cj->split) {
-
       /* Activate the drifts if the cells are local. */
       if (cell_is_active_gravity(ci, e) || cell_is_active_gravity(cj, e)) {
         if (ci->nodeID == engine_rank) cell_activate_drift_gpart(ci, s);
@@ -3268,7 +2729,6 @@ void cell_activate_subcell_grav_tasks(struct cell *ci, struct cell *cj,
     }
     /* Ok, we can still recurse */
     else {
-
       /* Recover the multipole information */
       const struct gravity_tensors *const multi_i = ci->grav.multipole;
       const struct gravity_tensors *const multi_j = cj->grav.multipole;
@@ -3277,7 +2737,6 @@ void cell_activate_subcell_grav_tasks(struct cell *ci, struct cell *cj,
 
       if (ri_max > rj_max) {
         if (ci->split) {
-
           /* Loop over ci's children */
           for (int k = 0; k < 8; k++) {
             if (ci->progeny[k] != NULL)
@@ -3285,7 +2744,6 @@ void cell_activate_subcell_grav_tasks(struct cell *ci, struct cell *cj,
           }
 
         } else if (cj->split) {
-
           /* Loop over cj's children */
           for (int k = 0; k < 8; k++) {
             if (cj->progeny[k] != NULL)
@@ -3297,7 +2755,6 @@ void cell_activate_subcell_grav_tasks(struct cell *ci, struct cell *cj,
         }
       } else if (rj_max >= ri_max) {
         if (cj->split) {
-
           /* Loop over cj's children */
           for (int k = 0; k < 8; k++) {
             if (cj->progeny[k] != NULL)
@@ -3305,7 +2762,6 @@ void cell_activate_subcell_grav_tasks(struct cell *ci, struct cell *cj,
           }
 
         } else if (ci->split) {
-
           /* Loop over ci's children */
           for (int k = 0; k < 8; k++) {
             if (ci->progeny[k] != NULL)
@@ -3329,7 +2785,6 @@ void cell_activate_subcell_grav_tasks(struct cell *ci, struct cell *cj,
  */
 void cell_activate_subcell_external_grav_tasks(struct cell *ci,
                                                struct scheduler *s) {
-
   /* Some constants */
   const struct space *sp = s->space;
   const struct engine *e = sp->e;
@@ -3339,7 +2794,6 @@ void cell_activate_subcell_external_grav_tasks(struct cell *ci,
 
   /* Recurse? */
   if (ci->split) {
-
     /* Loop over all progenies (no need for pairs for self-gravity) */
     for (int j = 0; j < 8; j++) {
       if (ci->progeny[j] != NULL) {
@@ -3347,7 +2801,6 @@ void cell_activate_subcell_external_grav_tasks(struct cell *ci,
       }
     }
   } else {
-
     /* We have reached the bottom of the tree: activate gpart drift */
     cell_activate_drift_gpart(ci, s);
   }
@@ -3363,7 +2816,6 @@ void cell_activate_subcell_external_grav_tasks(struct cell *ci,
  * @return 1 If the space needs rebuilding. 0 otherwise.
  */
 int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) {
-
   struct engine *e = s->space->e;
   const int nodeID = e->nodeID;
   const int with_limiter = (e->policy & engine_policy_limiter);
@@ -3423,7 +2875,6 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) {
 
     /* Only interested in pair interactions as of here. */
     if (t->type == task_type_pair || t->type == task_type_sub_pair) {
-
       /* Check whether there was too much particle motion, i.e. the
          cell neighbour conditions were violated. */
       if (cell_need_rebuild_for_hydro_pair(ci, cj)) rebuild = 1;
@@ -3431,7 +2882,6 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) {
 #ifdef WITH_MPI
       /* Activate the send/recv tasks. */
       if (ci_nodeID != nodeID) {
-
         /* If the local cell is active, receive data from the foreign cell. */
         if (cj_active) {
           scheduler_activate(s, ci->mpi.hydro.recv_xv);
@@ -3454,7 +2904,6 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) {
 
         /* Is the foreign cell active and will need stuff from us? */
         if (ci_active) {
-
           scheduler_activate_send(s, cj->mpi.hydro.send_xv, ci_nodeID);
 
           /* Drift the cell which will be sent; note that not all sent
@@ -3477,7 +2926,6 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) {
           scheduler_activate_send(s, cj->mpi.hydro.send_ti, ci_nodeID);
 
       } else if (cj_nodeID != nodeID) {
-
         /* If the local cell is active, receive data from the foreign cell. */
         if (ci_active) {
           scheduler_activate(s, cj->mpi.hydro.recv_xv);
@@ -3500,7 +2948,6 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) {
 
         /* Is the foreign cell active and will need stuff from us? */
         if (cj_active) {
-
           scheduler_activate_send(s, ci->mpi.hydro.send_xv, cj_nodeID);
 
           /* Drift the cell which will be sent; note that not all sent
@@ -3510,7 +2957,6 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) {
 
           /* If the local cell is also active, more stuff will be needed. */
           if (ci_active) {
-
             scheduler_activate_send(s, ci->mpi.hydro.send_rho, cj_nodeID);
 
 #ifdef EXTRA_HYDRO_LOOP
@@ -3529,7 +2975,6 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) {
 
   /* Unskip all the other task types. */
   if (c->nodeID == nodeID && cell_is_active_hydro(c, e)) {
-
     for (struct link *l = c->hydro.gradient; l != NULL; l = l->next)
       scheduler_activate(s, l->t);
     for (struct link *l = c->hydro.force; l != NULL; l = l->next)
@@ -3568,7 +3013,6 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) {
  * @return 1 If the space needs rebuilding. 0 otherwise.
  */
 int cell_unskip_gravity_tasks(struct cell *c, struct scheduler *s) {
-
   struct engine *e = s->space->e;
   const int nodeID = e->nodeID;
   int rebuild = 0;
@@ -3591,7 +3035,6 @@ int cell_unskip_gravity_tasks(struct cell *c, struct scheduler *s) {
     /* Only activate tasks that involve a local active cell. */
     if ((ci_active && ci_nodeID == nodeID) ||
         (cj_active && cj_nodeID == nodeID)) {
-
       scheduler_activate(s, t);
 
       /* Set the drifting flags */
@@ -3610,11 +3053,9 @@ int cell_unskip_gravity_tasks(struct cell *c, struct scheduler *s) {
     }
 
     if (t->type == task_type_pair) {
-
 #ifdef WITH_MPI
       /* Activate the send/recv tasks. */
       if (ci_nodeID != nodeID) {
-
         /* If the local cell is active, receive data from the foreign cell. */
         if (cj_active) scheduler_activate(s, ci->mpi.grav.recv);
 
@@ -3623,7 +3064,6 @@ int cell_unskip_gravity_tasks(struct cell *c, struct scheduler *s) {
 
         /* Is the foreign cell active and will need stuff from us? */
         if (ci_active) {
-
           scheduler_activate_send(s, cj->mpi.grav.send, ci_nodeID);
 
           /* Drift the cell which will be sent at the level at which it is
@@ -3637,7 +3077,6 @@ int cell_unskip_gravity_tasks(struct cell *c, struct scheduler *s) {
           scheduler_activate_send(s, cj->mpi.grav.send_ti, ci_nodeID);
 
       } else if (cj_nodeID != nodeID) {
-
         /* If the local cell is active, receive data from the foreign cell. */
         if (ci_active) scheduler_activate(s, cj->mpi.grav.recv);
 
@@ -3646,7 +3085,6 @@ int cell_unskip_gravity_tasks(struct cell *c, struct scheduler *s) {
 
         /* Is the foreign cell active and will need stuff from us? */
         if (cj_active) {
-
           scheduler_activate_send(s, ci->mpi.grav.send, cj_nodeID);
 
           /* Drift the cell which will be sent at the level at which it is
@@ -3664,7 +3102,6 @@ int cell_unskip_gravity_tasks(struct cell *c, struct scheduler *s) {
   }
 
   for (struct link *l = c->grav.mm; l != NULL; l = l->next) {
-
     struct task *t = l->t;
     struct cell *ci = t->ci;
     struct cell *cj = t->cj;
@@ -3685,14 +3122,12 @@ int cell_unskip_gravity_tasks(struct cell *c, struct scheduler *s) {
     /* Only activate tasks that involve a local active cell. */
     if ((ci_active && ci_nodeID == nodeID) ||
         (cj_active && cj_nodeID == nodeID)) {
-
       scheduler_activate(s, t);
     }
   }
 
   /* Unskip all the other task types. */
   if (c->nodeID == nodeID && cell_is_active_gravity(c, e)) {
-
     if (c->grav.init != NULL) scheduler_activate(s, c->grav.init);
     if (c->grav.init_out != NULL) scheduler_activate(s, c->grav.init_out);
     if (c->kick1 != NULL) scheduler_activate(s, c->kick1);
@@ -3726,7 +3161,6 @@ int cell_unskip_gravity_tasks(struct cell *c, struct scheduler *s) {
  * @return 1 If the space needs rebuilding. 0 otherwise.
  */
 int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s) {
-
   struct engine *e = s->space->e;
   const int nodeID = e->nodeID;
   int rebuild = 0;
@@ -3759,11 +3193,9 @@ int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s) {
     /* Only activate tasks that involve a local active cell. */
     if ((ci_active || cj_active) &&
         (ci_nodeID == nodeID || cj_nodeID == nodeID)) {
-
       scheduler_activate(s, t);
 
       if (t->type == task_type_pair) {
-
         /* Do ci */
         if (ci_active) {
           /* stars for ci */
@@ -3810,7 +3242,6 @@ int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s) {
 
     /* Only interested in pair interactions as of here. */
     if (t->type == task_type_pair || t->type == task_type_sub_pair) {
-
       /* Check whether there was too much particle motion, i.e. the
          cell neighbour conditions were violated. */
       if (cell_need_rebuild_for_stars_pair(ci, cj)) rebuild = 1;
@@ -3819,7 +3250,6 @@ int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s) {
 #ifdef WITH_MPI
       /* Activate the send/recv tasks. */
       if (ci_nodeID != nodeID) {
-
         if (cj_active) {
           scheduler_activate(s, ci->mpi.hydro.recv_xv);
           scheduler_activate(s, ci->mpi.hydro.recv_rho);
@@ -3848,7 +3278,6 @@ int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s) {
         }
 
       } else if (cj_nodeID != nodeID) {
-
         /* If the local cell is active, receive data from the foreign cell. */
         if (ci_active) {
           scheduler_activate(s, cj->mpi.hydro.recv_xv);
@@ -3905,20 +3334,16 @@ int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s) {
     }
 
     else if (t->type == task_type_pair || t->type == task_type_sub_pair) {
-
       /* We only want to activate the task if the cell is active and is
          going to update some gas on the *local* node */
       if ((ci_nodeID == nodeID && cj_nodeID == nodeID) &&
           (ci_active || cj_active)) {
-
         scheduler_activate(s, t);
 
       } else if ((ci_nodeID == nodeID && cj_nodeID != nodeID) && (cj_active)) {
-
         scheduler_activate(s, t);
 
       } else if ((ci_nodeID != nodeID && cj_nodeID == nodeID) && (ci_active)) {
-
         scheduler_activate(s, t);
       }
     }
@@ -3928,7 +3353,6 @@ int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s) {
 
   /* Unskip all the other task types. */
   if (c->nodeID == nodeID && cell_is_active_stars(c, e)) {
-
     if (c->stars.ghost != NULL) scheduler_activate(s, c->stars.ghost);
     if (c->stars.stars_in != NULL) scheduler_activate(s, c->stars.stars_in);
     if (c->stars.stars_out != NULL) scheduler_activate(s, c->stars.stars_out);
@@ -3951,7 +3375,6 @@ int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s) {
  */
 void cell_set_super(struct cell *c, struct cell *super, const int with_hydro,
                     const int with_grav) {
-
   /* Are we in a cell which is either the hydro or gravity super? */
   if (super == NULL && ((with_hydro && c->hydro.super != NULL) ||
                         (with_grav && c->grav.super != NULL)))
@@ -3975,7 +3398,6 @@ void cell_set_super(struct cell *c, struct cell *super, const int with_hydro,
  * tree.
  */
 void cell_set_super_hydro(struct cell *c, struct cell *super_hydro) {
-
   /* Are we in a cell with some kind of self/pair task ? */
   if (super_hydro == NULL && c->hydro.density != NULL) super_hydro = c;
 
@@ -3997,7 +3419,6 @@ void cell_set_super_hydro(struct cell *c, struct cell *super_hydro) {
  * the tree.
  */
 void cell_set_super_gravity(struct cell *c, struct cell *super_gravity) {
-
   /* Are we in a cell with some kind of self/pair task ? */
   if (super_gravity == NULL && (c->grav.grav != NULL || c->grav.mm != NULL))
     super_gravity = c;
@@ -4020,7 +3441,6 @@ void cell_set_super_gravity(struct cell *c, struct cell *super_gravity) {
  * @param extra_data Unused parameter.
  */
 void cell_set_super_mapper(void *map_data, int num_elements, void *extra_data) {
-
   const struct engine *e = (const struct engine *)extra_data;
 
   const int with_hydro = (e->policy & engine_policy_hydro);
@@ -4055,7 +3475,6 @@ void cell_set_super_mapper(void *map_data, int num_elements, void *extra_data) {
  * @param c The #cell to probe.
  */
 int cell_has_tasks(struct cell *c) {
-
 #ifdef WITH_MPI
   if (c->timestep != NULL || c->mpi.hydro.recv_ti != NULL ||
       c->mpi.grav.recv_ti != NULL || c->mpi.stars.recv_ti != NULL)
@@ -4082,7 +3501,6 @@ int cell_has_tasks(struct cell *c) {
  * @param force Drift the particles irrespective of the #cell flags.
  */
 void cell_drift_part(struct cell *c, const struct engine *e, int force) {
-
   const int periodic = e->s->periodic;
   const double dim[3] = {e->s->dim[0], e->s->dim[1], e->s->dim[2]};
   const int with_cosmology = (e->policy & engine_policy_cosmology);
@@ -4110,7 +3528,6 @@ void cell_drift_part(struct cell *c, const struct engine *e, int force) {
 
   /* Early abort? */
   if (c->hydro.count == 0) {
-
     /* Clear the drift flags. */
     c->hydro.do_drift = 0;
     c->hydro.do_sub_drift = 0;
@@ -4125,7 +3542,6 @@ void cell_drift_part(struct cell *c, const struct engine *e, int force) {
 
   /* Are we not in a leaf ? */
   if (c->split && (force || c->hydro.do_sub_drift)) {
-
     /* Loop over the progeny and collect their data. */
     for (int k = 0; k < 8; k++) {
       if (c->progeny[k] != NULL) {
@@ -4150,7 +3566,6 @@ void cell_drift_part(struct cell *c, const struct engine *e, int force) {
     c->hydro.ti_old_part = ti_current;
 
   } else if (!c->split && force && ti_current > ti_old_part) {
-
     /* Drift from the last time the cell was drifted to the current time */
     double dt_drift, dt_kick_grav, dt_kick_hydro, dt_therm;
     if (with_cosmology) {
@@ -4172,7 +3587,6 @@ void cell_drift_part(struct cell *c, const struct engine *e, int force) {
     /* Loop over all the gas particles in the cell */
     const size_t nr_parts = c->hydro.count;
     for (size_t k = 0; k < nr_parts; k++) {
-
       /* Get a handle on the part. */
       struct part *const p = &parts[k];
       struct xpart *const xp = &xparts[k];
@@ -4204,7 +3618,6 @@ void cell_drift_part(struct cell *c, const struct engine *e, int force) {
 
       /* In non-periodic BC runs, remove particles that crossed the border */
       if (!periodic) {
-
         /* Did the particle leave the box?  */
         if ((p->x[0] > dim[0]) || (p->x[0] < 0.) ||  // x
             (p->x[1] > dim[1]) || (p->x[1] < 0.) ||  // y
@@ -4273,7 +3686,6 @@ void cell_drift_part(struct cell *c, const struct engine *e, int force) {
  * @param force Drift the particles irrespective of the #cell flags.
  */
 void cell_drift_gpart(struct cell *c, const struct engine *e, int force) {
-
   const int periodic = e->s->periodic;
   const double dim[3] = {e->s->dim[0], e->s->dim[1], e->s->dim[2]};
   const int with_cosmology = (e->policy & engine_policy_cosmology);
@@ -4294,7 +3706,6 @@ void cell_drift_gpart(struct cell *c, const struct engine *e, int force) {
 
   /* Early abort? */
   if (c->grav.count == 0) {
-
     /* Clear the drift flags. */
     c->grav.do_drift = 0;
     c->grav.do_sub_drift = 0;
@@ -4309,7 +3720,6 @@ void cell_drift_gpart(struct cell *c, const struct engine *e, int force) {
 
   /* Are we not in a leaf ? */
   if (c->split && (force || c->grav.do_sub_drift)) {
-
     /* Loop over the progeny and collect their data. */
     for (int k = 0; k < 8; k++) {
       if (c->progeny[k] != NULL) {
@@ -4324,7 +3734,6 @@ void cell_drift_gpart(struct cell *c, const struct engine *e, int force) {
     c->grav.ti_old_part = ti_current;
 
   } else if (!c->split && force && ti_current > ti_old_gpart) {
-
     /* Drift from the last time the cell was drifted to the current time */
     double dt_drift;
     if (with_cosmology) {
@@ -4337,7 +3746,6 @@ void cell_drift_gpart(struct cell *c, const struct engine *e, int force) {
     /* Loop over all the g-particles in the cell */
     const size_t nr_gparts = c->grav.count;
     for (size_t k = 0; k < nr_gparts; k++) {
-
       /* Get a handle on the gpart. */
       struct gpart *const gp = &gparts[k];
 
@@ -4361,7 +3769,6 @@ void cell_drift_gpart(struct cell *c, const struct engine *e, int force) {
 
       /* In non-periodic BC runs, remove particles that crossed the border */
       if (!periodic) {
-
         /* Did the particle leave the box?  */
         if ((gp->x[0] > dim[0]) || (gp->x[0] < 0.) ||  // x
             (gp->x[1] > dim[1]) || (gp->x[1] < 0.) ||  // y
@@ -4397,7 +3804,6 @@ void cell_drift_gpart(struct cell *c, const struct engine *e, int force) {
  * @param force Drift the particles irrespective of the #cell flags.
  */
 void cell_drift_spart(struct cell *c, const struct engine *e, int force) {
-
   const int periodic = e->s->periodic;
   const double dim[3] = {e->s->dim[0], e->s->dim[1], e->s->dim[2]};
   const int with_cosmology = (e->policy & engine_policy_cosmology);
@@ -4424,7 +3830,6 @@ void cell_drift_spart(struct cell *c, const struct engine *e, int force) {
 
   /* Early abort? */
   if (c->stars.count == 0) {
-
     /* Clear the drift flags. */
     c->stars.do_drift = 0;
     c->stars.do_sub_drift = 0;
@@ -4439,7 +3844,6 @@ void cell_drift_spart(struct cell *c, const struct engine *e, int force) {
 
   /* Are we not in a leaf ? */
   if (c->split && (force || c->stars.do_sub_drift)) {
-
     /* Loop over the progeny and collect their data. */
     for (int k = 0; k < 8; k++) {
       if (c->progeny[k] != NULL) {
@@ -4464,7 +3868,6 @@ void cell_drift_spart(struct cell *c, const struct engine *e, int force) {
     c->stars.ti_old_part = ti_current;
 
   } else if (!c->split && force && ti_current > ti_old_spart) {
-
     /* Drift from the last time the cell was drifted to the current time */
     double dt_drift;
     if (with_cosmology) {
@@ -4477,7 +3880,6 @@ void cell_drift_spart(struct cell *c, const struct engine *e, int force) {
     /* Loop over all the star particles in the cell */
     const size_t nr_sparts = c->stars.count;
     for (size_t k = 0; k < nr_sparts; k++) {
-
       /* Get a handle on the spart. */
       struct spart *const sp = &sparts[k];
 
@@ -4498,7 +3900,6 @@ void cell_drift_spart(struct cell *c, const struct engine *e, int force) {
 
       /* In non-periodic BC runs, remove particles that crossed the border */
       if (!periodic) {
-
         /* Did the particle leave the box?  */
         if ((sp->x[0] > dim[0]) || (sp->x[0] < 0.) ||  // x
             (sp->x[1] > dim[1]) || (sp->x[1] < 0.) ||  // y
@@ -4724,7 +4125,6 @@ void cell_drift_bpart(struct cell *c, const struct engine *e, int force) {
  * @param e The #engine (to get ti_current).
  */
 void cell_drift_all_multipoles(struct cell *c, const struct engine *e) {
-
   const integertime_t ti_old_multipole = c->grav.ti_old_multipole;
   const integertime_t ti_current = e->ti_current;
 
@@ -4746,7 +4146,6 @@ void cell_drift_all_multipoles(struct cell *c, const struct engine *e) {
 
   /* Are we not in a leaf ? */
   if (c->split) {
-
     /* Loop over the progeny and recurse. */
     for (int k = 0; k < 8; k++)
       if (c->progeny[k] != NULL) cell_drift_all_multipoles(c->progeny[k], e);
@@ -4766,7 +4165,6 @@ void cell_drift_all_multipoles(struct cell *c, const struct engine *e) {
  * @param e The #engine (to get ti_current).
  */
 void cell_drift_multipole(struct cell *c, const struct engine *e) {
-
   const integertime_t ti_old_multipole = c->grav.ti_old_multipole;
   const integertime_t ti_current = e->ti_current;
 
@@ -4796,7 +4194,6 @@ void cell_drift_multipole(struct cell *c, const struct engine *e) {
  * @param c The #cell to clean.
  */
 void cell_clear_stars_sort_flags(struct cell *c) {
-
   /* Recurse if possible */
   if (c->split) {
     for (int k = 0; k < 8; k++)
@@ -4823,7 +4220,6 @@ void cell_check_timesteps(struct cell *c) {
     for (int k = 0; k < 8; ++k)
       if (c->progeny[k] != NULL) cell_check_timesteps(c->progeny[k]);
   } else {
-
     if (c->nodeID == engine_rank)
       for (int i = 0; i < c->hydro.count; ++i)
         if (c->hydro.parts[i].time_bin == 0)
@@ -4836,7 +4232,6 @@ void cell_check_timesteps(struct cell *c) {
 
 void cell_check_spart_pos(const struct cell *c,
                           const struct spart *global_sparts) {
-
 #ifdef SWIFT_DEBUG_CHECKS
 
   /* Recurse */
@@ -4849,7 +4244,6 @@ void cell_check_spart_pos(const struct cell *c,
   struct spart *sparts = c->stars.parts;
   const int count = c->stars.count;
   for (int i = 0; i < count; ++i) {
-
     const struct spart *sp = &sparts[i];
     if ((sp->x[0] < c->loc[0] / space_stretch) ||
         (sp->x[1] < c->loc[1] / space_stretch) ||
@@ -4861,7 +4255,6 @@ void cell_check_spart_pos(const struct cell *c,
 
     if (sp->time_bin != time_bin_not_created &&
         sp->time_bin != time_bin_inhibited) {
-
       const struct gpart *gp = sp->gpart;
       if (gp == NULL && sp->time_bin != time_bin_not_created)
         error("Unlinked spart!");
@@ -4890,12 +4283,10 @@ void cell_recursively_shift_sparts(struct cell *c,
                                    const int progeny_list[space_cell_maxdepth],
                                    const int main_branch) {
   if (c->split) {
-
     /* No need to recurse in progenies located before the insestion point */
     const int first_progeny = main_branch ? progeny_list[(int)c->depth] : 0;
 
     for (int k = first_progeny; k < 8; ++k) {
-
       if (c->progeny[k] != NULL)
         cell_recursively_shift_sparts(c->progeny[k], progeny_list,
                                       main_branch && (k == first_progeny));
@@ -4926,7 +4317,6 @@ void cell_recursively_shift_sparts(struct cell *c,
  * bin.
  */
 struct spart *cell_add_spart(struct engine *e, struct cell *const c) {
-
   /* Perform some basic consitency checks */
   if (c->nodeID != engine_rank) error("Adding spart on a foreign node");
   if (c->grav.ti_old_part != e->ti_current) error("Undrifted cell!");
@@ -4942,7 +4332,6 @@ struct spart *cell_add_spart(struct engine *e, struct cell *const c) {
      each level */
   struct cell *top = c;
   while (top->parent != NULL) {
-
     /* What is the progeny index of the cell? */
     for (int k = 0; k < 8; ++k) {
       if (top->parent->progeny[k] == top) {
@@ -4968,7 +4357,6 @@ struct spart *cell_add_spart(struct engine *e, struct cell *const c) {
 
   /* Are there any extra particles left? */
   if (top->stars.count == top->stars.count_total - 1) {
-
     /* Release the local lock before exiting. */
     if (lock_unlock(&top->stars.star_formation_lock) != 0)
       error("Failed to unlock the top-level cell.");
@@ -4986,7 +4374,6 @@ struct spart *cell_add_spart(struct engine *e, struct cell *const c) {
 #endif
 
   if (n_copy > 0) {
-
     // MATTHIEU: This can be improved. We don't need to copy everything, just
     // need to swap a few particles.
     memmove(&c->stars.parts[1], &c->stars.parts[0],
@@ -5056,7 +4443,6 @@ struct spart *cell_add_spart(struct engine *e, struct cell *const c) {
  */
 void cell_remove_part(const struct engine *e, struct cell *c, struct part *p,
                       struct xpart *xp) {
-
   /* Quick cross-check */
   if (c->nodeID != e->nodeID)
     error("Can't remove a particle in a foreign cell.");
@@ -5086,7 +4472,6 @@ void cell_remove_part(const struct engine *e, struct cell *c, struct part *p,
  */
 void cell_remove_gpart(const struct engine *e, struct cell *c,
                        struct gpart *gp) {
-
   /* Quick cross-check */
   if (c->nodeID != e->nodeID)
     error("Can't remove a particle in a foreign cell.");
@@ -5106,7 +4491,6 @@ void cell_remove_gpart(const struct engine *e, struct cell *c,
  */
 void cell_remove_spart(const struct engine *e, struct cell *c,
                        struct spart *sp) {
-
   /* Quick cross-check */
   if (c->nodeID != e->nodeID)
     error("Can't remove a particle in a foreign cell.");
@@ -5170,7 +4554,6 @@ void cell_remove_bpart(const struct engine *e, struct cell *c,
  */
 struct gpart *cell_convert_part_to_gpart(const struct engine *e, struct cell *c,
                                          struct part *p, struct xpart *xp) {
-
   /* Quick cross-checks */
   if (c->nodeID != e->nodeID)
     error("Can't remove a particle in a foreign cell.");
@@ -5216,7 +4599,6 @@ struct gpart *cell_convert_part_to_gpart(const struct engine *e, struct cell *c,
  */
 struct gpart *cell_convert_spart_to_gpart(const struct engine *e,
                                           struct cell *c, struct spart *sp) {
-
   /* Quick cross-check */
   if (c->nodeID != e->nodeID)
     error("Can't remove a particle in a foreign cell.");
@@ -5263,7 +4645,6 @@ struct gpart *cell_convert_spart_to_gpart(const struct engine *e,
  */
 struct spart *cell_convert_part_to_spart(struct engine *e, struct cell *c,
                                          struct part *p, struct xpart *xp) {
-
   /* Quick cross-check */
   if (c->nodeID != e->nodeID)
     error("Can't remove a particle in a foreign cell.");
@@ -5321,7 +4702,6 @@ struct spart *cell_convert_part_to_spart(struct engine *e, struct cell *c,
  * first #part in the global array in the space structure (for re-linking).
  */
 void cell_reorder_extra_parts(struct cell *c, const ptrdiff_t parts_offset) {
-
   struct part *parts = c->hydro.parts;
   struct xpart *xparts = c->hydro.xparts;
   const int count_real = c->hydro.count;
@@ -5334,7 +4714,6 @@ void cell_reorder_extra_parts(struct cell *c, const ptrdiff_t parts_offset) {
   /* Find extra particles */
   for (int i = 0; i < count_real; ++i) {
     if (parts[i].time_bin == time_bin_not_created) {
-
       /* Find the first non-extra particle after the end of the
          real particles */
       while (parts[first_not_extra].time_bin == time_bin_not_created) {
@@ -5375,7 +4754,6 @@ void cell_reorder_extra_parts(struct cell *c, const ptrdiff_t parts_offset) {
  * first #spart in the global array in the space structure (for re-linking).
  */
 void cell_reorder_extra_sparts(struct cell *c, const ptrdiff_t sparts_offset) {
-
   struct spart *sparts = c->stars.parts;
   const int count_real = c->stars.count;
 
@@ -5387,7 +4765,6 @@ void cell_reorder_extra_sparts(struct cell *c, const ptrdiff_t sparts_offset) {
   /* Find extra particles */
   for (int i = 0; i < count_real; ++i) {
     if (sparts[i].time_bin == time_bin_not_created) {
-
       /* Find the first non-extra particle after the end of the
          real particles */
       while (sparts[first_not_extra].time_bin == time_bin_not_created) {
@@ -5433,7 +4810,6 @@ void cell_reorder_extra_sparts(struct cell *c, const ptrdiff_t sparts_offset) {
  */
 void cell_reorder_extra_gparts(struct cell *c, struct part *parts,
                                struct spart *sparts) {
-
   struct gpart *gparts = c->grav.parts;
   const int count_real = c->grav.count;
 
@@ -5445,7 +4821,6 @@ void cell_reorder_extra_gparts(struct cell *c, struct part *parts,
   /* Find extra particles */
   for (int i = 0; i < count_real; ++i) {
     if (gparts[i].time_bin == time_bin_not_created) {
-
       /* Find the first non-extra particle after the end of the
          real particles */
       while (gparts[first_not_extra].time_bin == time_bin_not_created) {
@@ -5489,7 +4864,6 @@ void cell_reorder_extra_gparts(struct cell *c, struct part *parts,
  */
 int cell_can_use_pair_mm(const struct cell *ci, const struct cell *cj,
                          const struct engine *e, const struct space *s) {
-
   const double theta_crit2 = e->gravity_properties->theta_crit2;
   const int periodic = s->periodic;
   const double dim[3] = {s->dim[0], s->dim[1], s->dim[2]};
@@ -5528,7 +4902,6 @@ int cell_can_use_pair_mm(const struct cell *ci, const struct cell *cj,
 int cell_can_use_pair_mm_rebuild(const struct cell *ci, const struct cell *cj,
                                  const struct engine *e,
                                  const struct space *s) {
-
   const double theta_crit2 = e->gravity_properties->theta_crit2;
   const int periodic = s->periodic;
   const double dim[3] = {s->dim[0], s->dim[1], s->dim[2]};
diff --git a/src/cell.h b/src/cell.h
index f2b21daecd79bc829f79c407a1bc7ff3c00d2ef0..cf01e9666fb7bb46fb0fc4b222f974e04f2b3a3b 100644
--- a/src/cell.h
+++ b/src/cell.h
@@ -72,6 +72,17 @@ struct link {
   struct link *next;
 };
 
+/* Holds the pairs of progeny for each sid. */
+struct cell_split_pair {
+  int count;
+  struct {
+    int pid;
+    int pjd;
+    int sid;
+  } pairs[16];
+};
+extern struct cell_split_pair cell_split_pairs[13];
+
 /**
  * @brief Packed cell for information correct at rebuild time.
  *
diff --git a/src/runner.c b/src/runner.c
index e56b7f05132a64606249490b8a5c6816cf291951..e0dfbacebd9a074b515c25316f8d43272d2b3b14 100644
--- a/src/runner.c
+++ b/src/runner.c
@@ -442,7 +442,7 @@ void runner_do_stars_ghost(struct runner *r, struct cell *c, int timer) {
             /* Otherwise, sub-self interaction? */
             else if (l->t->type == task_type_sub_self)
               runner_dosub_subset_stars_density(r, finger, sparts, sid, scount,
-                                                NULL, -1, 1);
+                                                NULL, 1);
 
             /* Otherwise, sub-pair interaction? */
             else if (l->t->type == task_type_sub_pair) {
@@ -450,10 +450,10 @@ void runner_do_stars_ghost(struct runner *r, struct cell *c, int timer) {
               /* Left or right? */
               if (l->t->ci == finger)
                 runner_dosub_subset_stars_density(r, finger, sparts, sid,
-                                                  scount, l->t->cj, -1, 1);
+                                                  scount, l->t->cj, 1);
               else
                 runner_dosub_subset_stars_density(r, finger, sparts, sid,
-                                                  scount, l->t->ci, -1, 1);
+                                                  scount, l->t->ci, 1);
             }
           }
         }
@@ -1897,7 +1897,7 @@ void runner_do_ghost(struct runner *r, struct cell *c, int timer) {
             /* Otherwise, sub-self interaction? */
             else if (l->t->type == task_type_sub_self)
               runner_dosub_subset_density(r, finger, parts, pid, count, NULL,
-                                          -1, 1);
+                                          1);
 
             /* Otherwise, sub-pair interaction? */
             else if (l->t->type == task_type_sub_pair) {
@@ -1905,10 +1905,10 @@ void runner_do_ghost(struct runner *r, struct cell *c, int timer) {
               /* Left or right? */
               if (l->t->ci == finger)
                 runner_dosub_subset_density(r, finger, parts, pid, count,
-                                            l->t->cj, -1, 1);
+                                            l->t->cj, 1);
               else
                 runner_dosub_subset_density(r, finger, parts, pid, count,
-                                            l->t->ci, -1, 1);
+                                            l->t->ci, 1);
             }
           }
         }
@@ -3577,19 +3577,19 @@ void *runner_main(void *data) {
 
         case task_type_sub_pair:
           if (t->subtype == task_subtype_density)
-            runner_dosub_pair1_density(r, ci, cj, t->flags, 1);
+            runner_dosub_pair1_density(r, ci, cj, 1);
 #ifdef EXTRA_HYDRO_LOOP
           else if (t->subtype == task_subtype_gradient)
-            runner_dosub_pair1_gradient(r, ci, cj, t->flags, 1);
+            runner_dosub_pair1_gradient(r, ci, cj, 1);
 #endif
           else if (t->subtype == task_subtype_force)
-            runner_dosub_pair2_force(r, ci, cj, t->flags, 1);
+            runner_dosub_pair2_force(r, ci, cj, 1);
           else if (t->subtype == task_subtype_limiter)
-            runner_dosub_pair2_limiter(r, ci, cj, t->flags, 1);
+            runner_dosub_pair2_limiter(r, ci, cj, 1);
           else if (t->subtype == task_subtype_stars_density)
-            runner_dosub_pair_stars_density(r, ci, cj, t->flags, 1);
+            runner_dosub_pair_stars_density(r, ci, cj, 1);
           else if (t->subtype == task_subtype_stars_feedback)
-            runner_dosub_pair_stars_feedback(r, ci, cj, t->flags, 1);
+            runner_dosub_pair_stars_feedback(r, ci, cj, 1);
           else
             error("Unknown/invalid task subtype (%d).", t->subtype);
           break;
diff --git a/src/runner_doiact.h b/src/runner_doiact.h
index 854f8b898df93be93bb020a46606a415170fe980..635d41a95d320dd99eb806c9aec61127e8c7e42d 100644
--- a/src/runner_doiact.h
+++ b/src/runner_doiact.h
@@ -2216,13 +2216,12 @@ void DOSELF2_BRANCH(struct runner *r, struct cell *c) {
  * @param r The #runner.
  * @param ci The first #cell.
  * @param cj The second #cell.
- * @param sid The direction linking the cells
  * @param gettimer Do we have a timer ?
  *
  * @todo Hard-code the sid on the recursive calls to avoid the
  * redundant computations to find the sid on-the-fly.
  */
-void DOSUB_PAIR1(struct runner *r, struct cell *ci, struct cell *cj, int sid,
+void DOSUB_PAIR1(struct runner *r, struct cell *ci, struct cell *cj,
                  int gettimer) {
 
   struct space *s = r->e->s;
@@ -2234,210 +2233,20 @@ void DOSUB_PAIR1(struct runner *r, struct cell *ci, struct cell *cj, int sid,
   if (!cell_is_active_hydro(ci, e) && !cell_is_active_hydro(cj, e)) return;
   if (ci->hydro.count == 0 || cj->hydro.count == 0) return;
 
-  /* Get the type of pair if not specified explicitly. */
+  /* Get the type of pair and flip ci/cj if needed. */
   double shift[3];
-  sid = space_getsid(s, &ci, &cj, shift);
+  const int sid = space_getsid(s, &ci, &cj, shift);
 
   /* Recurse? */
   if (cell_can_recurse_in_pair_hydro_task(ci) &&
       cell_can_recurse_in_pair_hydro_task(cj)) {
-
-    /* Different types of flags. */
-    switch (sid) {
-
-      /* Regular sub-cell interactions of a single cell. */
-      case 0: /* (  1 ,  1 ,  1 ) */
-        if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[7], cj->progeny[0], -1, 0);
-        break;
-
-      case 1: /* (  1 ,  1 ,  0 ) */
-        if (ci->progeny[6] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[6], cj->progeny[0], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[6], cj->progeny[1], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[7], cj->progeny[0], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[7], cj->progeny[1], -1, 0);
-        break;
-
-      case 2: /* (  1 ,  1 , -1 ) */
-        if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[6], cj->progeny[1], -1, 0);
-        break;
-
-      case 3: /* (  1 ,  0 ,  1 ) */
-        if (ci->progeny[5] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[5], cj->progeny[0], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[5], cj->progeny[2], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[7], cj->progeny[0], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[7], cj->progeny[2], -1, 0);
-        break;
-
-      case 4: /* (  1 ,  0 ,  0 ) */
-        if (ci->progeny[4] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[4], cj->progeny[0], -1, 0);
-        if (ci->progeny[4] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[4], cj->progeny[1], -1, 0);
-        if (ci->progeny[4] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[4], cj->progeny[2], -1, 0);
-        if (ci->progeny[4] != NULL && cj->progeny[3] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[4], cj->progeny[3], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[5], cj->progeny[0], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[5], cj->progeny[1], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[5], cj->progeny[2], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[3] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[5], cj->progeny[3], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[6], cj->progeny[0], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[6], cj->progeny[1], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[6], cj->progeny[2], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[3] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[6], cj->progeny[3], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[7], cj->progeny[0], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[7], cj->progeny[1], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[7], cj->progeny[2], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[3] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[7], cj->progeny[3], -1, 0);
-        break;
-
-      case 5: /* (  1 ,  0 , -1 ) */
-        if (ci->progeny[4] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[4], cj->progeny[1], -1, 0);
-        if (ci->progeny[4] != NULL && cj->progeny[3] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[4], cj->progeny[3], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[6], cj->progeny[1], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[3] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[6], cj->progeny[3], -1, 0);
-        break;
-
-      case 6: /* (  1 , -1 ,  1 ) */
-        if (ci->progeny[5] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[5], cj->progeny[2], -1, 0);
-        break;
-
-      case 7: /* (  1 , -1 ,  0 ) */
-        if (ci->progeny[4] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[4], cj->progeny[2], -1, 0);
-        if (ci->progeny[4] != NULL && cj->progeny[3] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[4], cj->progeny[3], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[5], cj->progeny[2], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[3] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[5], cj->progeny[3], -1, 0);
-        break;
-
-      case 8: /* (  1 , -1 , -1 ) */
-        if (ci->progeny[4] != NULL && cj->progeny[3] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[4], cj->progeny[3], -1, 0);
-        break;
-
-      case 9: /* (  0 ,  1 ,  1 ) */
-        if (ci->progeny[3] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[3], cj->progeny[0], -1, 0);
-        if (ci->progeny[3] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[3], cj->progeny[4], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[7], cj->progeny[0], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[7], cj->progeny[4], -1, 0);
-        break;
-
-      case 10: /* (  0 ,  1 ,  0 ) */
-        if (ci->progeny[2] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[2], cj->progeny[0], -1, 0);
-        if (ci->progeny[2] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[2], cj->progeny[1], -1, 0);
-        if (ci->progeny[2] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[2], cj->progeny[4], -1, 0);
-        if (ci->progeny[2] != NULL && cj->progeny[5] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[2], cj->progeny[5], -1, 0);
-        if (ci->progeny[3] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[3], cj->progeny[0], -1, 0);
-        if (ci->progeny[3] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[3], cj->progeny[1], -1, 0);
-        if (ci->progeny[3] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[3], cj->progeny[4], -1, 0);
-        if (ci->progeny[3] != NULL && cj->progeny[5] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[3], cj->progeny[5], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[6], cj->progeny[0], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[6], cj->progeny[1], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[6], cj->progeny[4], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[5] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[6], cj->progeny[5], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[7], cj->progeny[0], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[7], cj->progeny[1], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[7], cj->progeny[4], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[5] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[7], cj->progeny[5], -1, 0);
-        break;
-
-      case 11: /* (  0 ,  1 , -1 ) */
-        if (ci->progeny[2] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[2], cj->progeny[1], -1, 0);
-        if (ci->progeny[2] != NULL && cj->progeny[5] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[2], cj->progeny[5], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[6], cj->progeny[1], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[5] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[6], cj->progeny[5], -1, 0);
-        break;
-
-      case 12: /* (  0 ,  0 ,  1 ) */
-        if (ci->progeny[1] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[1], cj->progeny[0], -1, 0);
-        if (ci->progeny[1] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[1], cj->progeny[2], -1, 0);
-        if (ci->progeny[1] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[1], cj->progeny[4], -1, 0);
-        if (ci->progeny[1] != NULL && cj->progeny[6] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[1], cj->progeny[6], -1, 0);
-        if (ci->progeny[3] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[3], cj->progeny[0], -1, 0);
-        if (ci->progeny[3] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[3], cj->progeny[2], -1, 0);
-        if (ci->progeny[3] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[3], cj->progeny[4], -1, 0);
-        if (ci->progeny[3] != NULL && cj->progeny[6] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[3], cj->progeny[6], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[5], cj->progeny[0], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[5], cj->progeny[2], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[5], cj->progeny[4], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[6] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[5], cj->progeny[6], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[7], cj->progeny[0], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[7], cj->progeny[2], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[7], cj->progeny[4], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[6] != NULL)
-          DOSUB_PAIR1(r, ci->progeny[7], cj->progeny[6], -1, 0);
-        break;
+    struct cell_split_pair *csp = &cell_split_pairs[sid];
+    for (int k = 0; k < csp->count; k++) {
+      const int pid = csp->pairs[k].pid;
+      const int pjd = csp->pairs[k].pjd;
+      if (ci->progeny[pid] != NULL && cj->progeny[pjd] != NULL)
+        DOSUB_PAIR1(r, ci->progeny[pid], cj->progeny[pjd], 0);
     }
-
   }
 
   /* Otherwise, compute the pair directly. */
@@ -2491,7 +2300,7 @@ void DOSUB_SELF1(struct runner *r, struct cell *ci, int gettimer) {
         DOSUB_SELF1(r, ci->progeny[k], 0);
         for (int j = k + 1; j < 8; j++)
           if (ci->progeny[j] != NULL)
-            DOSUB_PAIR1(r, ci->progeny[k], ci->progeny[j], -1, 0);
+            DOSUB_PAIR1(r, ci->progeny[k], ci->progeny[j], 0);
       }
   }
 
@@ -2513,13 +2322,12 @@ void DOSUB_SELF1(struct runner *r, struct cell *ci, int gettimer) {
  * @param r The #runner.
  * @param ci The first #cell.
  * @param cj The second #cell.
- * @param sid The direction linking the cells
  * @param gettimer Do we have a timer ?
  *
  * @todo Hard-code the sid on the recursive calls to avoid the
  * redundant computations to find the sid on-the-fly.
  */
-void DOSUB_PAIR2(struct runner *r, struct cell *ci, struct cell *cj, int sid,
+void DOSUB_PAIR2(struct runner *r, struct cell *ci, struct cell *cj,
                  int gettimer) {
 
   const struct engine *e = r->e;
@@ -2531,210 +2339,20 @@ void DOSUB_PAIR2(struct runner *r, struct cell *ci, struct cell *cj, int sid,
   if (!cell_is_active_hydro(ci, e) && !cell_is_active_hydro(cj, e)) return;
   if (ci->hydro.count == 0 || cj->hydro.count == 0) return;
 
-  /* Get the type of pair if not specified explicitly. */
+  /* Get the type of pair and flip ci/cj if needed. */
   double shift[3];
-  sid = space_getsid(s, &ci, &cj, shift);
+  const int sid = space_getsid(s, &ci, &cj, shift);
 
   /* Recurse? */
   if (cell_can_recurse_in_pair_hydro_task(ci) &&
       cell_can_recurse_in_pair_hydro_task(cj)) {
-
-    /* Different types of flags. */
-    switch (sid) {
-
-      /* Regular sub-cell interactions of a single cell. */
-      case 0: /* (  1 ,  1 ,  1 ) */
-        if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[7], cj->progeny[0], -1, 0);
-        break;
-
-      case 1: /* (  1 ,  1 ,  0 ) */
-        if (ci->progeny[6] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[6], cj->progeny[0], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[6], cj->progeny[1], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[7], cj->progeny[0], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[7], cj->progeny[1], -1, 0);
-        break;
-
-      case 2: /* (  1 ,  1 , -1 ) */
-        if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[6], cj->progeny[1], -1, 0);
-        break;
-
-      case 3: /* (  1 ,  0 ,  1 ) */
-        if (ci->progeny[5] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[5], cj->progeny[0], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[5], cj->progeny[2], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[7], cj->progeny[0], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[7], cj->progeny[2], -1, 0);
-        break;
-
-      case 4: /* (  1 ,  0 ,  0 ) */
-        if (ci->progeny[4] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[4], cj->progeny[0], -1, 0);
-        if (ci->progeny[4] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[4], cj->progeny[1], -1, 0);
-        if (ci->progeny[4] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[4], cj->progeny[2], -1, 0);
-        if (ci->progeny[4] != NULL && cj->progeny[3] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[4], cj->progeny[3], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[5], cj->progeny[0], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[5], cj->progeny[1], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[5], cj->progeny[2], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[3] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[5], cj->progeny[3], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[6], cj->progeny[0], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[6], cj->progeny[1], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[6], cj->progeny[2], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[3] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[6], cj->progeny[3], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[7], cj->progeny[0], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[7], cj->progeny[1], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[7], cj->progeny[2], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[3] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[7], cj->progeny[3], -1, 0);
-        break;
-
-      case 5: /* (  1 ,  0 , -1 ) */
-        if (ci->progeny[4] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[4], cj->progeny[1], -1, 0);
-        if (ci->progeny[4] != NULL && cj->progeny[3] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[4], cj->progeny[3], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[6], cj->progeny[1], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[3] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[6], cj->progeny[3], -1, 0);
-        break;
-
-      case 6: /* (  1 , -1 ,  1 ) */
-        if (ci->progeny[5] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[5], cj->progeny[2], -1, 0);
-        break;
-
-      case 7: /* (  1 , -1 ,  0 ) */
-        if (ci->progeny[4] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[4], cj->progeny[2], -1, 0);
-        if (ci->progeny[4] != NULL && cj->progeny[3] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[4], cj->progeny[3], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[5], cj->progeny[2], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[3] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[5], cj->progeny[3], -1, 0);
-        break;
-
-      case 8: /* (  1 , -1 , -1 ) */
-        if (ci->progeny[4] != NULL && cj->progeny[3] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[4], cj->progeny[3], -1, 0);
-        break;
-
-      case 9: /* (  0 ,  1 ,  1 ) */
-        if (ci->progeny[3] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[3], cj->progeny[0], -1, 0);
-        if (ci->progeny[3] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[3], cj->progeny[4], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[7], cj->progeny[0], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[7], cj->progeny[4], -1, 0);
-        break;
-
-      case 10: /* (  0 ,  1 ,  0 ) */
-        if (ci->progeny[2] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[2], cj->progeny[0], -1, 0);
-        if (ci->progeny[2] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[2], cj->progeny[1], -1, 0);
-        if (ci->progeny[2] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[2], cj->progeny[4], -1, 0);
-        if (ci->progeny[2] != NULL && cj->progeny[5] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[2], cj->progeny[5], -1, 0);
-        if (ci->progeny[3] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[3], cj->progeny[0], -1, 0);
-        if (ci->progeny[3] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[3], cj->progeny[1], -1, 0);
-        if (ci->progeny[3] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[3], cj->progeny[4], -1, 0);
-        if (ci->progeny[3] != NULL && cj->progeny[5] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[3], cj->progeny[5], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[6], cj->progeny[0], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[6], cj->progeny[1], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[6], cj->progeny[4], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[5] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[6], cj->progeny[5], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[7], cj->progeny[0], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[7], cj->progeny[1], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[7], cj->progeny[4], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[5] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[7], cj->progeny[5], -1, 0);
-        break;
-
-      case 11: /* (  0 ,  1 , -1 ) */
-        if (ci->progeny[2] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[2], cj->progeny[1], -1, 0);
-        if (ci->progeny[2] != NULL && cj->progeny[5] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[2], cj->progeny[5], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[6], cj->progeny[1], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[5] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[6], cj->progeny[5], -1, 0);
-        break;
-
-      case 12: /* (  0 ,  0 ,  1 ) */
-        if (ci->progeny[1] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[1], cj->progeny[0], -1, 0);
-        if (ci->progeny[1] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[1], cj->progeny[2], -1, 0);
-        if (ci->progeny[1] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[1], cj->progeny[4], -1, 0);
-        if (ci->progeny[1] != NULL && cj->progeny[6] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[1], cj->progeny[6], -1, 0);
-        if (ci->progeny[3] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[3], cj->progeny[0], -1, 0);
-        if (ci->progeny[3] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[3], cj->progeny[2], -1, 0);
-        if (ci->progeny[3] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[3], cj->progeny[4], -1, 0);
-        if (ci->progeny[3] != NULL && cj->progeny[6] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[3], cj->progeny[6], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[5], cj->progeny[0], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[5], cj->progeny[2], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[5], cj->progeny[4], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[6] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[5], cj->progeny[6], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[7], cj->progeny[0], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[7], cj->progeny[2], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[7], cj->progeny[4], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[6] != NULL)
-          DOSUB_PAIR2(r, ci->progeny[7], cj->progeny[6], -1, 0);
-        break;
+    struct cell_split_pair *csp = &cell_split_pairs[sid];
+    for (int k = 0; k < csp->count; k++) {
+      const int pid = csp->pairs[k].pid;
+      const int pjd = csp->pairs[k].pjd;
+      if (ci->progeny[pid] != NULL && cj->progeny[pjd] != NULL)
+        DOSUB_PAIR2(r, ci->progeny[pid], cj->progeny[pjd], 0);
     }
-
   }
 
   /* Otherwise, compute the pair directly. */
@@ -2788,7 +2406,7 @@ void DOSUB_SELF2(struct runner *r, struct cell *ci, int gettimer) {
         DOSUB_SELF2(r, ci->progeny[k], 0);
         for (int j = k + 1; j < 8; j++)
           if (ci->progeny[j] != NULL)
-            DOSUB_PAIR2(r, ci->progeny[k], ci->progeny[j], -1, 0);
+            DOSUB_PAIR2(r, ci->progeny[k], ci->progeny[j], 0);
       }
 
   }
@@ -2801,7 +2419,7 @@ void DOSUB_SELF2(struct runner *r, struct cell *ci, int gettimer) {
 }
 
 void DOSUB_SUBSET(struct runner *r, struct cell *ci, struct part *parts,
-                  int *ind, int count, struct cell *cj, int sid, int gettimer) {
+                  int *ind, int count, struct cell *cj, int gettimer) {
 
   const struct engine *e = r->e;
   struct space *s = e->s;
@@ -2836,10 +2454,10 @@ void DOSUB_SUBSET(struct runner *r, struct cell *ci, struct part *parts,
     if (cell_can_recurse_in_self_hydro_task(ci)) {
 
       /* Loop over all progeny. */
-      DOSUB_SUBSET(r, sub, parts, ind, count, NULL, -1, 0);
+      DOSUB_SUBSET(r, sub, parts, ind, count, NULL, 0);
       for (int j = 0; j < 8; j++)
         if (ci->progeny[j] != sub && ci->progeny[j] != NULL)
-          DOSUB_SUBSET(r, sub, parts, ind, count, ci->progeny[j], -1, 0);
+          DOSUB_SUBSET(r, sub, parts, ind, count, ci->progeny[j], 0);
 
     }
 
@@ -2855,510 +2473,21 @@ void DOSUB_SUBSET(struct runner *r, struct cell *ci, struct part *parts,
     if (cell_can_recurse_in_pair_hydro_task(ci) &&
         cell_can_recurse_in_pair_hydro_task(cj)) {
 
-      /* Get the type of pair if not specified explicitly. */
+      /* Get the type of pair and flip ci/cj if needed. */
       double shift[3] = {0.0, 0.0, 0.0};
-      sid = space_getsid(s, &ci, &cj, shift);
-
-      /* Different types of flags. */
-      switch (sid) {
-
-        /* Regular sub-cell interactions of a single cell. */
-        case 0: /* (  1 ,  1 ,  1 ) */
-          if (ci->progeny[7] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[7], parts, ind, count, cj->progeny[0],
-                         -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET(r, cj->progeny[0], parts, ind, count, ci->progeny[7],
-                         -1, 0);
-          break;
-
-        case 1: /* (  1 ,  1 ,  0 ) */
-          if (ci->progeny[6] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[6], parts, ind, count, cj->progeny[0],
-                         -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET(r, cj->progeny[0], parts, ind, count, ci->progeny[6],
-                         -1, 0);
-          if (ci->progeny[6] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[6], parts, ind, count, cj->progeny[1],
-                         -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET(r, cj->progeny[1], parts, ind, count, ci->progeny[6],
-                         -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[7], parts, ind, count, cj->progeny[0],
-                         -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET(r, cj->progeny[0], parts, ind, count, ci->progeny[7],
-                         -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[7], parts, ind, count, cj->progeny[1],
-                         -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET(r, cj->progeny[1], parts, ind, count, ci->progeny[7],
-                         -1, 0);
-          break;
-
-        case 2: /* (  1 ,  1 , -1 ) */
-          if (ci->progeny[6] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[6], parts, ind, count, cj->progeny[1],
-                         -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET(r, cj->progeny[1], parts, ind, count, ci->progeny[6],
-                         -1, 0);
-          break;
-
-        case 3: /* (  1 ,  0 ,  1 ) */
-          if (ci->progeny[5] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[5], parts, ind, count, cj->progeny[0],
-                         -1, 0);
-          if (ci->progeny[5] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET(r, cj->progeny[0], parts, ind, count, ci->progeny[5],
-                         -1, 0);
-          if (ci->progeny[5] == sub && cj->progeny[2] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[5], parts, ind, count, cj->progeny[2],
-                         -1, 0);
-          if (ci->progeny[5] != NULL && cj->progeny[2] == sub)
-            DOSUB_SUBSET(r, cj->progeny[2], parts, ind, count, ci->progeny[5],
-                         -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[7], parts, ind, count, cj->progeny[0],
-                         -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET(r, cj->progeny[0], parts, ind, count, ci->progeny[7],
-                         -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[2] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[7], parts, ind, count, cj->progeny[2],
-                         -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[2] == sub)
-            DOSUB_SUBSET(r, cj->progeny[2], parts, ind, count, ci->progeny[7],
-                         -1, 0);
-          break;
-
-        case 4: /* (  1 ,  0 ,  0 ) */
-          if (ci->progeny[4] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[4], parts, ind, count, cj->progeny[0],
-                         -1, 0);
-          if (ci->progeny[4] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET(r, cj->progeny[0], parts, ind, count, ci->progeny[4],
-                         -1, 0);
-          if (ci->progeny[4] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[4], parts, ind, count, cj->progeny[1],
-                         -1, 0);
-          if (ci->progeny[4] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET(r, cj->progeny[1], parts, ind, count, ci->progeny[4],
-                         -1, 0);
-          if (ci->progeny[4] == sub && cj->progeny[2] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[4], parts, ind, count, cj->progeny[2],
-                         -1, 0);
-          if (ci->progeny[4] != NULL && cj->progeny[2] == sub)
-            DOSUB_SUBSET(r, cj->progeny[2], parts, ind, count, ci->progeny[4],
-                         -1, 0);
-          if (ci->progeny[4] == sub && cj->progeny[3] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[4], parts, ind, count, cj->progeny[3],
-                         -1, 0);
-          if (ci->progeny[4] != NULL && cj->progeny[3] == sub)
-            DOSUB_SUBSET(r, cj->progeny[3], parts, ind, count, ci->progeny[4],
-                         -1, 0);
-          if (ci->progeny[5] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[5], parts, ind, count, cj->progeny[0],
-                         -1, 0);
-          if (ci->progeny[5] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET(r, cj->progeny[0], parts, ind, count, ci->progeny[5],
-                         -1, 0);
-          if (ci->progeny[5] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[5], parts, ind, count, cj->progeny[1],
-                         -1, 0);
-          if (ci->progeny[5] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET(r, cj->progeny[1], parts, ind, count, ci->progeny[5],
-                         -1, 0);
-          if (ci->progeny[5] == sub && cj->progeny[2] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[5], parts, ind, count, cj->progeny[2],
-                         -1, 0);
-          if (ci->progeny[5] != NULL && cj->progeny[2] == sub)
-            DOSUB_SUBSET(r, cj->progeny[2], parts, ind, count, ci->progeny[5],
-                         -1, 0);
-          if (ci->progeny[5] == sub && cj->progeny[3] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[5], parts, ind, count, cj->progeny[3],
-                         -1, 0);
-          if (ci->progeny[5] != NULL && cj->progeny[3] == sub)
-            DOSUB_SUBSET(r, cj->progeny[3], parts, ind, count, ci->progeny[5],
-                         -1, 0);
-          if (ci->progeny[6] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[6], parts, ind, count, cj->progeny[0],
-                         -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET(r, cj->progeny[0], parts, ind, count, ci->progeny[6],
-                         -1, 0);
-          if (ci->progeny[6] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[6], parts, ind, count, cj->progeny[1],
-                         -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET(r, cj->progeny[1], parts, ind, count, ci->progeny[6],
-                         -1, 0);
-          if (ci->progeny[6] == sub && cj->progeny[2] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[6], parts, ind, count, cj->progeny[2],
-                         -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[2] == sub)
-            DOSUB_SUBSET(r, cj->progeny[2], parts, ind, count, ci->progeny[6],
-                         -1, 0);
-          if (ci->progeny[6] == sub && cj->progeny[3] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[6], parts, ind, count, cj->progeny[3],
-                         -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[3] == sub)
-            DOSUB_SUBSET(r, cj->progeny[3], parts, ind, count, ci->progeny[6],
-                         -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[7], parts, ind, count, cj->progeny[0],
-                         -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET(r, cj->progeny[0], parts, ind, count, ci->progeny[7],
-                         -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[7], parts, ind, count, cj->progeny[1],
-                         -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET(r, cj->progeny[1], parts, ind, count, ci->progeny[7],
-                         -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[2] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[7], parts, ind, count, cj->progeny[2],
-                         -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[2] == sub)
-            DOSUB_SUBSET(r, cj->progeny[2], parts, ind, count, ci->progeny[7],
-                         -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[3] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[7], parts, ind, count, cj->progeny[3],
-                         -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[3] == sub)
-            DOSUB_SUBSET(r, cj->progeny[3], parts, ind, count, ci->progeny[7],
-                         -1, 0);
-          break;
-
-        case 5: /* (  1 ,  0 , -1 ) */
-          if (ci->progeny[4] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[4], parts, ind, count, cj->progeny[1],
-                         -1, 0);
-          if (ci->progeny[4] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET(r, cj->progeny[1], parts, ind, count, ci->progeny[4],
-                         -1, 0);
-          if (ci->progeny[4] == sub && cj->progeny[3] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[4], parts, ind, count, cj->progeny[3],
-                         -1, 0);
-          if (ci->progeny[4] != NULL && cj->progeny[3] == sub)
-            DOSUB_SUBSET(r, cj->progeny[3], parts, ind, count, ci->progeny[4],
-                         -1, 0);
-          if (ci->progeny[6] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[6], parts, ind, count, cj->progeny[1],
-                         -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET(r, cj->progeny[1], parts, ind, count, ci->progeny[6],
-                         -1, 0);
-          if (ci->progeny[6] == sub && cj->progeny[3] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[6], parts, ind, count, cj->progeny[3],
-                         -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[3] == sub)
-            DOSUB_SUBSET(r, cj->progeny[3], parts, ind, count, ci->progeny[6],
-                         -1, 0);
-          break;
-
-        case 6: /* (  1 , -1 ,  1 ) */
-          if (ci->progeny[5] == sub && cj->progeny[2] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[5], parts, ind, count, cj->progeny[2],
-                         -1, 0);
-          if (ci->progeny[5] != NULL && cj->progeny[2] == sub)
-            DOSUB_SUBSET(r, cj->progeny[2], parts, ind, count, ci->progeny[5],
-                         -1, 0);
-          break;
-
-        case 7: /* (  1 , -1 ,  0 ) */
-          if (ci->progeny[4] == sub && cj->progeny[2] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[4], parts, ind, count, cj->progeny[2],
-                         -1, 0);
-          if (ci->progeny[4] != NULL && cj->progeny[2] == sub)
-            DOSUB_SUBSET(r, cj->progeny[2], parts, ind, count, ci->progeny[4],
-                         -1, 0);
-          if (ci->progeny[4] == sub && cj->progeny[3] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[4], parts, ind, count, cj->progeny[3],
-                         -1, 0);
-          if (ci->progeny[4] != NULL && cj->progeny[3] == sub)
-            DOSUB_SUBSET(r, cj->progeny[3], parts, ind, count, ci->progeny[4],
-                         -1, 0);
-          if (ci->progeny[5] == sub && cj->progeny[2] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[5], parts, ind, count, cj->progeny[2],
-                         -1, 0);
-          if (ci->progeny[5] != NULL && cj->progeny[2] == sub)
-            DOSUB_SUBSET(r, cj->progeny[2], parts, ind, count, ci->progeny[5],
-                         -1, 0);
-          if (ci->progeny[5] == sub && cj->progeny[3] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[5], parts, ind, count, cj->progeny[3],
-                         -1, 0);
-          if (ci->progeny[5] != NULL && cj->progeny[3] == sub)
-            DOSUB_SUBSET(r, cj->progeny[3], parts, ind, count, ci->progeny[5],
-                         -1, 0);
-          break;
-
-        case 8: /* (  1 , -1 , -1 ) */
-          if (ci->progeny[4] == sub && cj->progeny[3] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[4], parts, ind, count, cj->progeny[3],
-                         -1, 0);
-          if (ci->progeny[4] != NULL && cj->progeny[3] == sub)
-            DOSUB_SUBSET(r, cj->progeny[3], parts, ind, count, ci->progeny[4],
-                         -1, 0);
-          break;
-
-        case 9: /* (  0 ,  1 ,  1 ) */
-          if (ci->progeny[3] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[3], parts, ind, count, cj->progeny[0],
-                         -1, 0);
-          if (ci->progeny[3] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET(r, cj->progeny[0], parts, ind, count, ci->progeny[3],
-                         -1, 0);
-          if (ci->progeny[3] == sub && cj->progeny[4] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[3], parts, ind, count, cj->progeny[4],
-                         -1, 0);
-          if (ci->progeny[3] != NULL && cj->progeny[4] == sub)
-            DOSUB_SUBSET(r, cj->progeny[4], parts, ind, count, ci->progeny[3],
-                         -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[7], parts, ind, count, cj->progeny[0],
-                         -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET(r, cj->progeny[0], parts, ind, count, ci->progeny[7],
-                         -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[4] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[7], parts, ind, count, cj->progeny[4],
-                         -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[4] == sub)
-            DOSUB_SUBSET(r, cj->progeny[4], parts, ind, count, ci->progeny[7],
-                         -1, 0);
-          break;
-
-        case 10: /* (  0 ,  1 ,  0 ) */
-          if (ci->progeny[2] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[2], parts, ind, count, cj->progeny[0],
-                         -1, 0);
-          if (ci->progeny[2] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET(r, cj->progeny[0], parts, ind, count, ci->progeny[2],
-                         -1, 0);
-          if (ci->progeny[2] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[2], parts, ind, count, cj->progeny[1],
-                         -1, 0);
-          if (ci->progeny[2] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET(r, cj->progeny[1], parts, ind, count, ci->progeny[2],
-                         -1, 0);
-          if (ci->progeny[2] == sub && cj->progeny[4] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[2], parts, ind, count, cj->progeny[4],
-                         -1, 0);
-          if (ci->progeny[2] != NULL && cj->progeny[4] == sub)
-            DOSUB_SUBSET(r, cj->progeny[4], parts, ind, count, ci->progeny[2],
-                         -1, 0);
-          if (ci->progeny[2] == sub && cj->progeny[5] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[2], parts, ind, count, cj->progeny[5],
-                         -1, 0);
-          if (ci->progeny[2] != NULL && cj->progeny[5] == sub)
-            DOSUB_SUBSET(r, cj->progeny[5], parts, ind, count, ci->progeny[2],
-                         -1, 0);
-          if (ci->progeny[3] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[3], parts, ind, count, cj->progeny[0],
-                         -1, 0);
-          if (ci->progeny[3] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET(r, cj->progeny[0], parts, ind, count, ci->progeny[3],
-                         -1, 0);
-          if (ci->progeny[3] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[3], parts, ind, count, cj->progeny[1],
-                         -1, 0);
-          if (ci->progeny[3] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET(r, cj->progeny[1], parts, ind, count, ci->progeny[3],
-                         -1, 0);
-          if (ci->progeny[3] == sub && cj->progeny[4] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[3], parts, ind, count, cj->progeny[4],
-                         -1, 0);
-          if (ci->progeny[3] != NULL && cj->progeny[4] == sub)
-            DOSUB_SUBSET(r, cj->progeny[4], parts, ind, count, ci->progeny[3],
-                         -1, 0);
-          if (ci->progeny[3] == sub && cj->progeny[5] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[3], parts, ind, count, cj->progeny[5],
-                         -1, 0);
-          if (ci->progeny[3] != NULL && cj->progeny[5] == sub)
-            DOSUB_SUBSET(r, cj->progeny[5], parts, ind, count, ci->progeny[3],
-                         -1, 0);
-          if (ci->progeny[6] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[6], parts, ind, count, cj->progeny[0],
-                         -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET(r, cj->progeny[0], parts, ind, count, ci->progeny[6],
-                         -1, 0);
-          if (ci->progeny[6] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[6], parts, ind, count, cj->progeny[1],
-                         -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET(r, cj->progeny[1], parts, ind, count, ci->progeny[6],
-                         -1, 0);
-          if (ci->progeny[6] == sub && cj->progeny[4] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[6], parts, ind, count, cj->progeny[4],
-                         -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[4] == sub)
-            DOSUB_SUBSET(r, cj->progeny[4], parts, ind, count, ci->progeny[6],
-                         -1, 0);
-          if (ci->progeny[6] == sub && cj->progeny[5] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[6], parts, ind, count, cj->progeny[5],
-                         -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[5] == sub)
-            DOSUB_SUBSET(r, cj->progeny[5], parts, ind, count, ci->progeny[6],
-                         -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[7], parts, ind, count, cj->progeny[0],
-                         -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET(r, cj->progeny[0], parts, ind, count, ci->progeny[7],
-                         -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[7], parts, ind, count, cj->progeny[1],
-                         -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET(r, cj->progeny[1], parts, ind, count, ci->progeny[7],
-                         -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[4] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[7], parts, ind, count, cj->progeny[4],
-                         -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[4] == sub)
-            DOSUB_SUBSET(r, cj->progeny[4], parts, ind, count, ci->progeny[7],
-                         -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[5] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[7], parts, ind, count, cj->progeny[5],
-                         -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[5] == sub)
-            DOSUB_SUBSET(r, cj->progeny[5], parts, ind, count, ci->progeny[7],
-                         -1, 0);
-          break;
-
-        case 11: /* (  0 ,  1 , -1 ) */
-          if (ci->progeny[2] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[2], parts, ind, count, cj->progeny[1],
-                         -1, 0);
-          if (ci->progeny[2] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET(r, cj->progeny[1], parts, ind, count, ci->progeny[2],
-                         -1, 0);
-          if (ci->progeny[2] == sub && cj->progeny[5] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[2], parts, ind, count, cj->progeny[5],
-                         -1, 0);
-          if (ci->progeny[2] != NULL && cj->progeny[5] == sub)
-            DOSUB_SUBSET(r, cj->progeny[5], parts, ind, count, ci->progeny[2],
-                         -1, 0);
-          if (ci->progeny[6] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[6], parts, ind, count, cj->progeny[1],
-                         -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET(r, cj->progeny[1], parts, ind, count, ci->progeny[6],
-                         -1, 0);
-          if (ci->progeny[6] == sub && cj->progeny[5] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[6], parts, ind, count, cj->progeny[5],
-                         -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[5] == sub)
-            DOSUB_SUBSET(r, cj->progeny[5], parts, ind, count, ci->progeny[6],
-                         -1, 0);
-          break;
-
-        case 12: /* (  0 ,  0 ,  1 ) */
-          if (ci->progeny[1] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[1], parts, ind, count, cj->progeny[0],
-                         -1, 0);
-          if (ci->progeny[1] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET(r, cj->progeny[0], parts, ind, count, ci->progeny[1],
-                         -1, 0);
-          if (ci->progeny[1] == sub && cj->progeny[2] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[1], parts, ind, count, cj->progeny[2],
-                         -1, 0);
-          if (ci->progeny[1] != NULL && cj->progeny[2] == sub)
-            DOSUB_SUBSET(r, cj->progeny[2], parts, ind, count, ci->progeny[1],
-                         -1, 0);
-          if (ci->progeny[1] == sub && cj->progeny[4] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[1], parts, ind, count, cj->progeny[4],
-                         -1, 0);
-          if (ci->progeny[1] != NULL && cj->progeny[4] == sub)
-            DOSUB_SUBSET(r, cj->progeny[4], parts, ind, count, ci->progeny[1],
-                         -1, 0);
-          if (ci->progeny[1] == sub && cj->progeny[6] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[1], parts, ind, count, cj->progeny[6],
-                         -1, 0);
-          if (ci->progeny[1] != NULL && cj->progeny[6] == sub)
-            DOSUB_SUBSET(r, cj->progeny[6], parts, ind, count, ci->progeny[1],
-                         -1, 0);
-          if (ci->progeny[3] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[3], parts, ind, count, cj->progeny[0],
-                         -1, 0);
-          if (ci->progeny[3] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET(r, cj->progeny[0], parts, ind, count, ci->progeny[3],
-                         -1, 0);
-          if (ci->progeny[3] == sub && cj->progeny[2] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[3], parts, ind, count, cj->progeny[2],
-                         -1, 0);
-          if (ci->progeny[3] != NULL && cj->progeny[2] == sub)
-            DOSUB_SUBSET(r, cj->progeny[2], parts, ind, count, ci->progeny[3],
-                         -1, 0);
-          if (ci->progeny[3] == sub && cj->progeny[4] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[3], parts, ind, count, cj->progeny[4],
-                         -1, 0);
-          if (ci->progeny[3] != NULL && cj->progeny[4] == sub)
-            DOSUB_SUBSET(r, cj->progeny[4], parts, ind, count, ci->progeny[3],
-                         -1, 0);
-          if (ci->progeny[3] == sub && cj->progeny[6] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[3], parts, ind, count, cj->progeny[6],
-                         -1, 0);
-          if (ci->progeny[3] != NULL && cj->progeny[6] == sub)
-            DOSUB_SUBSET(r, cj->progeny[6], parts, ind, count, ci->progeny[3],
-                         -1, 0);
-          if (ci->progeny[5] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[5], parts, ind, count, cj->progeny[0],
-                         -1, 0);
-          if (ci->progeny[5] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET(r, cj->progeny[0], parts, ind, count, ci->progeny[5],
-                         -1, 0);
-          if (ci->progeny[5] == sub && cj->progeny[2] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[5], parts, ind, count, cj->progeny[2],
-                         -1, 0);
-          if (ci->progeny[5] != NULL && cj->progeny[2] == sub)
-            DOSUB_SUBSET(r, cj->progeny[2], parts, ind, count, ci->progeny[5],
-                         -1, 0);
-          if (ci->progeny[5] == sub && cj->progeny[4] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[5], parts, ind, count, cj->progeny[4],
-                         -1, 0);
-          if (ci->progeny[5] != NULL && cj->progeny[4] == sub)
-            DOSUB_SUBSET(r, cj->progeny[4], parts, ind, count, ci->progeny[5],
-                         -1, 0);
-          if (ci->progeny[5] == sub && cj->progeny[6] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[5], parts, ind, count, cj->progeny[6],
-                         -1, 0);
-          if (ci->progeny[5] != NULL && cj->progeny[6] == sub)
-            DOSUB_SUBSET(r, cj->progeny[6], parts, ind, count, ci->progeny[5],
-                         -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[7], parts, ind, count, cj->progeny[0],
-                         -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET(r, cj->progeny[0], parts, ind, count, ci->progeny[7],
-                         -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[2] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[7], parts, ind, count, cj->progeny[2],
-                         -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[2] == sub)
-            DOSUB_SUBSET(r, cj->progeny[2], parts, ind, count, ci->progeny[7],
-                         -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[4] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[7], parts, ind, count, cj->progeny[4],
-                         -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[4] == sub)
-            DOSUB_SUBSET(r, cj->progeny[4], parts, ind, count, ci->progeny[7],
-                         -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[6] != NULL)
-            DOSUB_SUBSET(r, ci->progeny[7], parts, ind, count, cj->progeny[6],
-                         -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[6] == sub)
-            DOSUB_SUBSET(r, cj->progeny[6], parts, ind, count, ci->progeny[7],
-                         -1, 0);
-          break;
+      const int sid = space_getsid(s, &ci, &cj, shift);
+
+      struct cell_split_pair *csp = &cell_split_pairs[sid];
+      for (int k = 0; k < csp->count; k++) {
+        const int pid = csp->pairs[k].pid;
+        const int pjd = csp->pairs[k].pjd;
+        if (ci->progeny[pid] == sub && cj->progeny[pjd] != NULL)
+          DOSUB_SUBSET(r, ci->progeny[pid], parts, ind, count, cj->progeny[pjd],
+                       0);
+        if (ci->progeny[pid] != NULL && cj->progeny[pjd] == sub)
+          DOSUB_SUBSET(r, cj->progeny[pjd], parts, ind, count, ci->progeny[pid],
+                       0);
       }
-
     }
 
     /* Otherwise, compute the pair directly. */
diff --git a/src/runner_doiact_stars.h b/src/runner_doiact_stars.h
index da279fcd01a7f2a3fe900863f7564451f6e88406..be4f83f8137a1908f0d3dc7f321b2d11ea28bd3d 100644
--- a/src/runner_doiact_stars.h
+++ b/src/runner_doiact_stars.h
@@ -1019,8 +1019,7 @@ void DOPAIR1_SUBSET_BRANCH_STARS(struct runner *r, struct cell *restrict ci,
 }
 
 void DOSUB_SUBSET_STARS(struct runner *r, struct cell *ci, struct spart *sparts,
-                        int *ind, int scount, struct cell *cj, int sid,
-                        int gettimer) {
+                        int *ind, int scount, struct cell *cj, int gettimer) {
 
   const struct engine *e = r->e;
   struct space *s = e->s;
@@ -1052,11 +1051,10 @@ void DOSUB_SUBSET_STARS(struct runner *r, struct cell *ci, struct spart *sparts,
     if (cell_can_recurse_in_self_stars_task(ci)) {
 
       /* Loop over all progeny. */
-      DOSUB_SUBSET_STARS(r, sub, sparts, ind, scount, NULL, -1, 0);
+      DOSUB_SUBSET_STARS(r, sub, sparts, ind, scount, NULL, 0);
       for (int j = 0; j < 8; j++)
         if (ci->progeny[j] != sub && ci->progeny[j] != NULL)
-          DOSUB_SUBSET_STARS(r, sub, sparts, ind, scount, ci->progeny[j], -1,
-                             0);
+          DOSUB_SUBSET_STARS(r, sub, sparts, ind, scount, ci->progeny[j], 0);
 
     }
 
@@ -1072,510 +1070,21 @@ void DOSUB_SUBSET_STARS(struct runner *r, struct cell *ci, struct spart *sparts,
     if (cell_can_recurse_in_pair_stars_task(ci, cj) &&
         cell_can_recurse_in_pair_stars_task(cj, ci)) {
 
-      /* Get the type of pair if not specified explicitly. */
+      /* Get the type of pair and flip ci/cj if needed. */
       double shift[3] = {0.0, 0.0, 0.0};
-      sid = space_getsid(s, &ci, &cj, shift);
-
-      /* Different types of flags. */
-      switch (sid) {
-
-        /* Regular sub-cell interactions of a single cell. */
-        case 0: /* (  1 ,  1 ,  1 ) */
-          if (ci->progeny[7] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[7], sparts, ind, scount,
-                               cj->progeny[0], -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[0], sparts, ind, scount,
-                               ci->progeny[7], -1, 0);
-          break;
-
-        case 1: /* (  1 ,  1 ,  0 ) */
-          if (ci->progeny[6] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[6], sparts, ind, scount,
-                               cj->progeny[0], -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[0], sparts, ind, scount,
-                               ci->progeny[6], -1, 0);
-          if (ci->progeny[6] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[6], sparts, ind, scount,
-                               cj->progeny[1], -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[1], sparts, ind, scount,
-                               ci->progeny[6], -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[7], sparts, ind, scount,
-                               cj->progeny[0], -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[0], sparts, ind, scount,
-                               ci->progeny[7], -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[7], sparts, ind, scount,
-                               cj->progeny[1], -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[1], sparts, ind, scount,
-                               ci->progeny[7], -1, 0);
-          break;
-
-        case 2: /* (  1 ,  1 , -1 ) */
-          if (ci->progeny[6] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[6], sparts, ind, scount,
-                               cj->progeny[1], -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[1], sparts, ind, scount,
-                               ci->progeny[6], -1, 0);
-          break;
-
-        case 3: /* (  1 ,  0 ,  1 ) */
-          if (ci->progeny[5] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[5], sparts, ind, scount,
-                               cj->progeny[0], -1, 0);
-          if (ci->progeny[5] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[0], sparts, ind, scount,
-                               ci->progeny[5], -1, 0);
-          if (ci->progeny[5] == sub && cj->progeny[2] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[5], sparts, ind, scount,
-                               cj->progeny[2], -1, 0);
-          if (ci->progeny[5] != NULL && cj->progeny[2] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[2], sparts, ind, scount,
-                               ci->progeny[5], -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[7], sparts, ind, scount,
-                               cj->progeny[0], -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[0], sparts, ind, scount,
-                               ci->progeny[7], -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[2] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[7], sparts, ind, scount,
-                               cj->progeny[2], -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[2] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[2], sparts, ind, scount,
-                               ci->progeny[7], -1, 0);
-          break;
-
-        case 4: /* (  1 ,  0 ,  0 ) */
-          if (ci->progeny[4] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[4], sparts, ind, scount,
-                               cj->progeny[0], -1, 0);
-          if (ci->progeny[4] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[0], sparts, ind, scount,
-                               ci->progeny[4], -1, 0);
-          if (ci->progeny[4] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[4], sparts, ind, scount,
-                               cj->progeny[1], -1, 0);
-          if (ci->progeny[4] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[1], sparts, ind, scount,
-                               ci->progeny[4], -1, 0);
-          if (ci->progeny[4] == sub && cj->progeny[2] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[4], sparts, ind, scount,
-                               cj->progeny[2], -1, 0);
-          if (ci->progeny[4] != NULL && cj->progeny[2] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[2], sparts, ind, scount,
-                               ci->progeny[4], -1, 0);
-          if (ci->progeny[4] == sub && cj->progeny[3] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[4], sparts, ind, scount,
-                               cj->progeny[3], -1, 0);
-          if (ci->progeny[4] != NULL && cj->progeny[3] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[3], sparts, ind, scount,
-                               ci->progeny[4], -1, 0);
-          if (ci->progeny[5] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[5], sparts, ind, scount,
-                               cj->progeny[0], -1, 0);
-          if (ci->progeny[5] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[0], sparts, ind, scount,
-                               ci->progeny[5], -1, 0);
-          if (ci->progeny[5] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[5], sparts, ind, scount,
-                               cj->progeny[1], -1, 0);
-          if (ci->progeny[5] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[1], sparts, ind, scount,
-                               ci->progeny[5], -1, 0);
-          if (ci->progeny[5] == sub && cj->progeny[2] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[5], sparts, ind, scount,
-                               cj->progeny[2], -1, 0);
-          if (ci->progeny[5] != NULL && cj->progeny[2] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[2], sparts, ind, scount,
-                               ci->progeny[5], -1, 0);
-          if (ci->progeny[5] == sub && cj->progeny[3] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[5], sparts, ind, scount,
-                               cj->progeny[3], -1, 0);
-          if (ci->progeny[5] != NULL && cj->progeny[3] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[3], sparts, ind, scount,
-                               ci->progeny[5], -1, 0);
-          if (ci->progeny[6] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[6], sparts, ind, scount,
-                               cj->progeny[0], -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[0], sparts, ind, scount,
-                               ci->progeny[6], -1, 0);
-          if (ci->progeny[6] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[6], sparts, ind, scount,
-                               cj->progeny[1], -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[1], sparts, ind, scount,
-                               ci->progeny[6], -1, 0);
-          if (ci->progeny[6] == sub && cj->progeny[2] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[6], sparts, ind, scount,
-                               cj->progeny[2], -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[2] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[2], sparts, ind, scount,
-                               ci->progeny[6], -1, 0);
-          if (ci->progeny[6] == sub && cj->progeny[3] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[6], sparts, ind, scount,
-                               cj->progeny[3], -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[3] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[3], sparts, ind, scount,
-                               ci->progeny[6], -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[7], sparts, ind, scount,
-                               cj->progeny[0], -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[0], sparts, ind, scount,
-                               ci->progeny[7], -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[7], sparts, ind, scount,
-                               cj->progeny[1], -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[1], sparts, ind, scount,
-                               ci->progeny[7], -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[2] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[7], sparts, ind, scount,
-                               cj->progeny[2], -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[2] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[2], sparts, ind, scount,
-                               ci->progeny[7], -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[3] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[7], sparts, ind, scount,
-                               cj->progeny[3], -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[3] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[3], sparts, ind, scount,
-                               ci->progeny[7], -1, 0);
-          break;
-
-        case 5: /* (  1 ,  0 , -1 ) */
-          if (ci->progeny[4] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[4], sparts, ind, scount,
-                               cj->progeny[1], -1, 0);
-          if (ci->progeny[4] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[1], sparts, ind, scount,
-                               ci->progeny[4], -1, 0);
-          if (ci->progeny[4] == sub && cj->progeny[3] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[4], sparts, ind, scount,
-                               cj->progeny[3], -1, 0);
-          if (ci->progeny[4] != NULL && cj->progeny[3] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[3], sparts, ind, scount,
-                               ci->progeny[4], -1, 0);
-          if (ci->progeny[6] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[6], sparts, ind, scount,
-                               cj->progeny[1], -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[1], sparts, ind, scount,
-                               ci->progeny[6], -1, 0);
-          if (ci->progeny[6] == sub && cj->progeny[3] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[6], sparts, ind, scount,
-                               cj->progeny[3], -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[3] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[3], sparts, ind, scount,
-                               ci->progeny[6], -1, 0);
-          break;
-
-        case 6: /* (  1 , -1 ,  1 ) */
-          if (ci->progeny[5] == sub && cj->progeny[2] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[5], sparts, ind, scount,
-                               cj->progeny[2], -1, 0);
-          if (ci->progeny[5] != NULL && cj->progeny[2] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[2], sparts, ind, scount,
-                               ci->progeny[5], -1, 0);
-          break;
-
-        case 7: /* (  1 , -1 ,  0 ) */
-          if (ci->progeny[4] == sub && cj->progeny[2] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[4], sparts, ind, scount,
-                               cj->progeny[2], -1, 0);
-          if (ci->progeny[4] != NULL && cj->progeny[2] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[2], sparts, ind, scount,
-                               ci->progeny[4], -1, 0);
-          if (ci->progeny[4] == sub && cj->progeny[3] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[4], sparts, ind, scount,
-                               cj->progeny[3], -1, 0);
-          if (ci->progeny[4] != NULL && cj->progeny[3] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[3], sparts, ind, scount,
-                               ci->progeny[4], -1, 0);
-          if (ci->progeny[5] == sub && cj->progeny[2] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[5], sparts, ind, scount,
-                               cj->progeny[2], -1, 0);
-          if (ci->progeny[5] != NULL && cj->progeny[2] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[2], sparts, ind, scount,
-                               ci->progeny[5], -1, 0);
-          if (ci->progeny[5] == sub && cj->progeny[3] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[5], sparts, ind, scount,
-                               cj->progeny[3], -1, 0);
-          if (ci->progeny[5] != NULL && cj->progeny[3] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[3], sparts, ind, scount,
-                               ci->progeny[5], -1, 0);
-          break;
-
-        case 8: /* (  1 , -1 , -1 ) */
-          if (ci->progeny[4] == sub && cj->progeny[3] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[4], sparts, ind, scount,
-                               cj->progeny[3], -1, 0);
-          if (ci->progeny[4] != NULL && cj->progeny[3] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[3], sparts, ind, scount,
-                               ci->progeny[4], -1, 0);
-          break;
-
-        case 9: /* (  0 ,  1 ,  1 ) */
-          if (ci->progeny[3] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[3], sparts, ind, scount,
-                               cj->progeny[0], -1, 0);
-          if (ci->progeny[3] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[0], sparts, ind, scount,
-                               ci->progeny[3], -1, 0);
-          if (ci->progeny[3] == sub && cj->progeny[4] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[3], sparts, ind, scount,
-                               cj->progeny[4], -1, 0);
-          if (ci->progeny[3] != NULL && cj->progeny[4] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[4], sparts, ind, scount,
-                               ci->progeny[3], -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[7], sparts, ind, scount,
-                               cj->progeny[0], -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[0], sparts, ind, scount,
-                               ci->progeny[7], -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[4] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[7], sparts, ind, scount,
-                               cj->progeny[4], -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[4] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[4], sparts, ind, scount,
-                               ci->progeny[7], -1, 0);
-          break;
-
-        case 10: /* (  0 ,  1 ,  0 ) */
-          if (ci->progeny[2] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[2], sparts, ind, scount,
-                               cj->progeny[0], -1, 0);
-          if (ci->progeny[2] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[0], sparts, ind, scount,
-                               ci->progeny[2], -1, 0);
-          if (ci->progeny[2] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[2], sparts, ind, scount,
-                               cj->progeny[1], -1, 0);
-          if (ci->progeny[2] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[1], sparts, ind, scount,
-                               ci->progeny[2], -1, 0);
-          if (ci->progeny[2] == sub && cj->progeny[4] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[2], sparts, ind, scount,
-                               cj->progeny[4], -1, 0);
-          if (ci->progeny[2] != NULL && cj->progeny[4] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[4], sparts, ind, scount,
-                               ci->progeny[2], -1, 0);
-          if (ci->progeny[2] == sub && cj->progeny[5] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[2], sparts, ind, scount,
-                               cj->progeny[5], -1, 0);
-          if (ci->progeny[2] != NULL && cj->progeny[5] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[5], sparts, ind, scount,
-                               ci->progeny[2], -1, 0);
-          if (ci->progeny[3] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[3], sparts, ind, scount,
-                               cj->progeny[0], -1, 0);
-          if (ci->progeny[3] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[0], sparts, ind, scount,
-                               ci->progeny[3], -1, 0);
-          if (ci->progeny[3] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[3], sparts, ind, scount,
-                               cj->progeny[1], -1, 0);
-          if (ci->progeny[3] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[1], sparts, ind, scount,
-                               ci->progeny[3], -1, 0);
-          if (ci->progeny[3] == sub && cj->progeny[4] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[3], sparts, ind, scount,
-                               cj->progeny[4], -1, 0);
-          if (ci->progeny[3] != NULL && cj->progeny[4] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[4], sparts, ind, scount,
-                               ci->progeny[3], -1, 0);
-          if (ci->progeny[3] == sub && cj->progeny[5] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[3], sparts, ind, scount,
-                               cj->progeny[5], -1, 0);
-          if (ci->progeny[3] != NULL && cj->progeny[5] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[5], sparts, ind, scount,
-                               ci->progeny[3], -1, 0);
-          if (ci->progeny[6] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[6], sparts, ind, scount,
-                               cj->progeny[0], -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[0], sparts, ind, scount,
-                               ci->progeny[6], -1, 0);
-          if (ci->progeny[6] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[6], sparts, ind, scount,
-                               cj->progeny[1], -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[1], sparts, ind, scount,
-                               ci->progeny[6], -1, 0);
-          if (ci->progeny[6] == sub && cj->progeny[4] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[6], sparts, ind, scount,
-                               cj->progeny[4], -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[4] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[4], sparts, ind, scount,
-                               ci->progeny[6], -1, 0);
-          if (ci->progeny[6] == sub && cj->progeny[5] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[6], sparts, ind, scount,
-                               cj->progeny[5], -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[5] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[5], sparts, ind, scount,
-                               ci->progeny[6], -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[7], sparts, ind, scount,
-                               cj->progeny[0], -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[0], sparts, ind, scount,
-                               ci->progeny[7], -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[7], sparts, ind, scount,
-                               cj->progeny[1], -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[1], sparts, ind, scount,
-                               ci->progeny[7], -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[4] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[7], sparts, ind, scount,
-                               cj->progeny[4], -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[4] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[4], sparts, ind, scount,
-                               ci->progeny[7], -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[5] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[7], sparts, ind, scount,
-                               cj->progeny[5], -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[5] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[5], sparts, ind, scount,
-                               ci->progeny[7], -1, 0);
-          break;
-
-        case 11: /* (  0 ,  1 , -1 ) */
-          if (ci->progeny[2] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[2], sparts, ind, scount,
-                               cj->progeny[1], -1, 0);
-          if (ci->progeny[2] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[1], sparts, ind, scount,
-                               ci->progeny[2], -1, 0);
-          if (ci->progeny[2] == sub && cj->progeny[5] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[2], sparts, ind, scount,
-                               cj->progeny[5], -1, 0);
-          if (ci->progeny[2] != NULL && cj->progeny[5] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[5], sparts, ind, scount,
-                               ci->progeny[2], -1, 0);
-          if (ci->progeny[6] == sub && cj->progeny[1] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[6], sparts, ind, scount,
-                               cj->progeny[1], -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[1] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[1], sparts, ind, scount,
-                               ci->progeny[6], -1, 0);
-          if (ci->progeny[6] == sub && cj->progeny[5] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[6], sparts, ind, scount,
-                               cj->progeny[5], -1, 0);
-          if (ci->progeny[6] != NULL && cj->progeny[5] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[5], sparts, ind, scount,
-                               ci->progeny[6], -1, 0);
-          break;
-
-        case 12: /* (  0 ,  0 ,  1 ) */
-          if (ci->progeny[1] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[1], sparts, ind, scount,
-                               cj->progeny[0], -1, 0);
-          if (ci->progeny[1] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[0], sparts, ind, scount,
-                               ci->progeny[1], -1, 0);
-          if (ci->progeny[1] == sub && cj->progeny[2] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[1], sparts, ind, scount,
-                               cj->progeny[2], -1, 0);
-          if (ci->progeny[1] != NULL && cj->progeny[2] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[2], sparts, ind, scount,
-                               ci->progeny[1], -1, 0);
-          if (ci->progeny[1] == sub && cj->progeny[4] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[1], sparts, ind, scount,
-                               cj->progeny[4], -1, 0);
-          if (ci->progeny[1] != NULL && cj->progeny[4] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[4], sparts, ind, scount,
-                               ci->progeny[1], -1, 0);
-          if (ci->progeny[1] == sub && cj->progeny[6] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[1], sparts, ind, scount,
-                               cj->progeny[6], -1, 0);
-          if (ci->progeny[1] != NULL && cj->progeny[6] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[6], sparts, ind, scount,
-                               ci->progeny[1], -1, 0);
-          if (ci->progeny[3] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[3], sparts, ind, scount,
-                               cj->progeny[0], -1, 0);
-          if (ci->progeny[3] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[0], sparts, ind, scount,
-                               ci->progeny[3], -1, 0);
-          if (ci->progeny[3] == sub && cj->progeny[2] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[3], sparts, ind, scount,
-                               cj->progeny[2], -1, 0);
-          if (ci->progeny[3] != NULL && cj->progeny[2] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[2], sparts, ind, scount,
-                               ci->progeny[3], -1, 0);
-          if (ci->progeny[3] == sub && cj->progeny[4] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[3], sparts, ind, scount,
-                               cj->progeny[4], -1, 0);
-          if (ci->progeny[3] != NULL && cj->progeny[4] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[4], sparts, ind, scount,
-                               ci->progeny[3], -1, 0);
-          if (ci->progeny[3] == sub && cj->progeny[6] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[3], sparts, ind, scount,
-                               cj->progeny[6], -1, 0);
-          if (ci->progeny[3] != NULL && cj->progeny[6] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[6], sparts, ind, scount,
-                               ci->progeny[3], -1, 0);
-          if (ci->progeny[5] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[5], sparts, ind, scount,
-                               cj->progeny[0], -1, 0);
-          if (ci->progeny[5] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[0], sparts, ind, scount,
-                               ci->progeny[5], -1, 0);
-          if (ci->progeny[5] == sub && cj->progeny[2] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[5], sparts, ind, scount,
-                               cj->progeny[2], -1, 0);
-          if (ci->progeny[5] != NULL && cj->progeny[2] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[2], sparts, ind, scount,
-                               ci->progeny[5], -1, 0);
-          if (ci->progeny[5] == sub && cj->progeny[4] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[5], sparts, ind, scount,
-                               cj->progeny[4], -1, 0);
-          if (ci->progeny[5] != NULL && cj->progeny[4] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[4], sparts, ind, scount,
-                               ci->progeny[5], -1, 0);
-          if (ci->progeny[5] == sub && cj->progeny[6] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[5], sparts, ind, scount,
-                               cj->progeny[6], -1, 0);
-          if (ci->progeny[5] != NULL && cj->progeny[6] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[6], sparts, ind, scount,
-                               ci->progeny[5], -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[0] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[7], sparts, ind, scount,
-                               cj->progeny[0], -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[0] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[0], sparts, ind, scount,
-                               ci->progeny[7], -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[2] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[7], sparts, ind, scount,
-                               cj->progeny[2], -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[2] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[2], sparts, ind, scount,
-                               ci->progeny[7], -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[4] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[7], sparts, ind, scount,
-                               cj->progeny[4], -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[4] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[4], sparts, ind, scount,
-                               ci->progeny[7], -1, 0);
-          if (ci->progeny[7] == sub && cj->progeny[6] != NULL)
-            DOSUB_SUBSET_STARS(r, ci->progeny[7], sparts, ind, scount,
-                               cj->progeny[6], -1, 0);
-          if (ci->progeny[7] != NULL && cj->progeny[6] == sub)
-            DOSUB_SUBSET_STARS(r, cj->progeny[6], sparts, ind, scount,
-                               ci->progeny[7], -1, 0);
-          break;
+      const int sid = space_getsid(s, &ci, &cj, shift);
+
+      struct cell_split_pair *csp = &cell_split_pairs[sid];
+      for (int k = 0; k < csp->count; k++) {
+        const int pid = csp->pairs[k].pid;
+        const int pjd = csp->pairs[k].pjd;
+        if (ci->progeny[pid] == sub && cj->progeny[pjd] != NULL)
+          DOSUB_SUBSET_STARS(r, ci->progeny[pid], sparts, ind, scount,
+                             cj->progeny[pjd], 0);
+        if (ci->progeny[pid] != NULL && cj->progeny[pjd] == sub)
+          DOSUB_SUBSET_STARS(r, cj->progeny[pjd], sparts, ind, scount,
+                             ci->progeny[pid], 0);
       }
-
     }
 
     /* Otherwise, compute the pair directly. */
@@ -1735,14 +1244,13 @@ void DOPAIR1_BRANCH_STARS(struct runner *r, struct cell *ci, struct cell *cj) {
  * @param r The #runner.
  * @param ci The first #cell.
  * @param cj The second #cell.
- * @param sid The direction linking the cells
  * @param gettimer Do we have a timer ?
  *
  * @todo Hard-code the sid on the recursive calls to avoid the
  * redundant computations to find the sid on-the-fly.
  */
 void DOSUB_PAIR1_STARS(struct runner *r, struct cell *ci, struct cell *cj,
-                       int sid, int gettimer) {
+                       int gettimer) {
 
   TIMER_TIC;
 
@@ -1756,210 +1264,20 @@ void DOSUB_PAIR1_STARS(struct runner *r, struct cell *ci, struct cell *cj,
                            cell_is_active_stars(cj, e);
   if (!should_do_ci && !should_do_cj) return;
 
-  /* Get the type of pair if not specified explicitly. */
+  /* Get the type of pair and flip ci/cj if needed. */
   double shift[3];
-  sid = space_getsid(s, &ci, &cj, shift);
+  const int sid = space_getsid(s, &ci, &cj, shift);
 
   /* Recurse? */
   if (cell_can_recurse_in_pair_stars_task(ci, cj) &&
       cell_can_recurse_in_pair_stars_task(cj, ci)) {
-
-    /* Different types of flags. */
-    switch (sid) {
-
-      /* Regular sub-cell interactions of a single cell. */
-      case 0: /* (  1 ,  1 ,  1 ) */
-        if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[7], cj->progeny[0], -1, 0);
-        break;
-
-      case 1: /* (  1 ,  1 ,  0 ) */
-        if (ci->progeny[6] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[6], cj->progeny[0], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[6], cj->progeny[1], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[7], cj->progeny[0], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[7], cj->progeny[1], -1, 0);
-        break;
-
-      case 2: /* (  1 ,  1 , -1 ) */
-        if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[6], cj->progeny[1], -1, 0);
-        break;
-
-      case 3: /* (  1 ,  0 ,  1 ) */
-        if (ci->progeny[5] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[5], cj->progeny[0], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[5], cj->progeny[2], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[7], cj->progeny[0], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[7], cj->progeny[2], -1, 0);
-        break;
-
-      case 4: /* (  1 ,  0 ,  0 ) */
-        if (ci->progeny[4] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[4], cj->progeny[0], -1, 0);
-        if (ci->progeny[4] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[4], cj->progeny[1], -1, 0);
-        if (ci->progeny[4] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[4], cj->progeny[2], -1, 0);
-        if (ci->progeny[4] != NULL && cj->progeny[3] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[4], cj->progeny[3], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[5], cj->progeny[0], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[5], cj->progeny[1], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[5], cj->progeny[2], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[3] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[5], cj->progeny[3], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[6], cj->progeny[0], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[6], cj->progeny[1], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[6], cj->progeny[2], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[3] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[6], cj->progeny[3], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[7], cj->progeny[0], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[7], cj->progeny[1], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[7], cj->progeny[2], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[3] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[7], cj->progeny[3], -1, 0);
-        break;
-
-      case 5: /* (  1 ,  0 , -1 ) */
-        if (ci->progeny[4] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[4], cj->progeny[1], -1, 0);
-        if (ci->progeny[4] != NULL && cj->progeny[3] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[4], cj->progeny[3], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[6], cj->progeny[1], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[3] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[6], cj->progeny[3], -1, 0);
-        break;
-
-      case 6: /* (  1 , -1 ,  1 ) */
-        if (ci->progeny[5] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[5], cj->progeny[2], -1, 0);
-        break;
-
-      case 7: /* (  1 , -1 ,  0 ) */
-        if (ci->progeny[4] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[4], cj->progeny[2], -1, 0);
-        if (ci->progeny[4] != NULL && cj->progeny[3] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[4], cj->progeny[3], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[5], cj->progeny[2], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[3] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[5], cj->progeny[3], -1, 0);
-        break;
-
-      case 8: /* (  1 , -1 , -1 ) */
-        if (ci->progeny[4] != NULL && cj->progeny[3] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[4], cj->progeny[3], -1, 0);
-        break;
-
-      case 9: /* (  0 ,  1 ,  1 ) */
-        if (ci->progeny[3] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[3], cj->progeny[0], -1, 0);
-        if (ci->progeny[3] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[3], cj->progeny[4], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[7], cj->progeny[0], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[7], cj->progeny[4], -1, 0);
-        break;
-
-      case 10: /* (  0 ,  1 ,  0 ) */
-        if (ci->progeny[2] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[2], cj->progeny[0], -1, 0);
-        if (ci->progeny[2] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[2], cj->progeny[1], -1, 0);
-        if (ci->progeny[2] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[2], cj->progeny[4], -1, 0);
-        if (ci->progeny[2] != NULL && cj->progeny[5] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[2], cj->progeny[5], -1, 0);
-        if (ci->progeny[3] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[3], cj->progeny[0], -1, 0);
-        if (ci->progeny[3] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[3], cj->progeny[1], -1, 0);
-        if (ci->progeny[3] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[3], cj->progeny[4], -1, 0);
-        if (ci->progeny[3] != NULL && cj->progeny[5] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[3], cj->progeny[5], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[6], cj->progeny[0], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[6], cj->progeny[1], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[6], cj->progeny[4], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[5] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[6], cj->progeny[5], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[7], cj->progeny[0], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[7], cj->progeny[1], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[7], cj->progeny[4], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[5] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[7], cj->progeny[5], -1, 0);
-        break;
-
-      case 11: /* (  0 ,  1 , -1 ) */
-        if (ci->progeny[2] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[2], cj->progeny[1], -1, 0);
-        if (ci->progeny[2] != NULL && cj->progeny[5] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[2], cj->progeny[5], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[1] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[6], cj->progeny[1], -1, 0);
-        if (ci->progeny[6] != NULL && cj->progeny[5] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[6], cj->progeny[5], -1, 0);
-        break;
-
-      case 12: /* (  0 ,  0 ,  1 ) */
-        if (ci->progeny[1] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[1], cj->progeny[0], -1, 0);
-        if (ci->progeny[1] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[1], cj->progeny[2], -1, 0);
-        if (ci->progeny[1] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[1], cj->progeny[4], -1, 0);
-        if (ci->progeny[1] != NULL && cj->progeny[6] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[1], cj->progeny[6], -1, 0);
-        if (ci->progeny[3] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[3], cj->progeny[0], -1, 0);
-        if (ci->progeny[3] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[3], cj->progeny[2], -1, 0);
-        if (ci->progeny[3] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[3], cj->progeny[4], -1, 0);
-        if (ci->progeny[3] != NULL && cj->progeny[6] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[3], cj->progeny[6], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[5], cj->progeny[0], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[5], cj->progeny[2], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[5], cj->progeny[4], -1, 0);
-        if (ci->progeny[5] != NULL && cj->progeny[6] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[5], cj->progeny[6], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[0] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[7], cj->progeny[0], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[2] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[7], cj->progeny[2], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[4] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[7], cj->progeny[4], -1, 0);
-        if (ci->progeny[7] != NULL && cj->progeny[6] != NULL)
-          DOSUB_PAIR1_STARS(r, ci->progeny[7], cj->progeny[6], -1, 0);
-        break;
+    struct cell_split_pair *csp = &cell_split_pairs[sid];
+    for (int k = 0; k < csp->count; k++) {
+      const int pid = csp->pairs[k].pid;
+      const int pjd = csp->pairs[k].pjd;
+      if (ci->progeny[pid] != NULL && cj->progeny[pjd] != NULL)
+        DOSUB_PAIR1_STARS(r, ci->progeny[pid], cj->progeny[pjd], 0);
     }
-
   }
 
   /* Otherwise, compute the pair directly. */
@@ -2055,7 +1373,7 @@ void DOSUB_SELF1_STARS(struct runner *r, struct cell *ci, int gettimer) {
         DOSUB_SELF1_STARS(r, ci->progeny[k], 0);
         for (int j = k + 1; j < 8; j++)
           if (ci->progeny[j] != NULL)
-            DOSUB_PAIR1_STARS(r, ci->progeny[k], ci->progeny[j], -1, 0);
+            DOSUB_PAIR1_STARS(r, ci->progeny[k], ci->progeny[j], 0);
       }
   }
 
diff --git a/src/scheduler.c b/src/scheduler.c
index 6b50738d4055909174359480324c0fc995c8cffd..6dba5f1593c8bf050a260ded5061ebc54fc63310 100644
--- a/src/scheduler.c
+++ b/src/scheduler.c
@@ -65,7 +65,6 @@ void scheduler_clear_active(struct scheduler *s) { s->active_count = 0; }
  *        current index == s->size_unlock;
  */
 static void scheduler_extend_unlocks(struct scheduler *s) {
-
   /* Allocate the new buffer. */
   const int size_unlocks_new = s->size_unlocks * 2;
   struct task **unlocks_new = (struct task **)swift_malloc(
@@ -143,7 +142,6 @@ void scheduler_addunlock(struct scheduler *s, struct task *ta,
 int scheduler_get_number_relation(const struct scheduler *s,
                                   const struct task *ta,
                                   const struct task *tb) {
-
   int count = 0;
 
   /* loop over all tasks */
@@ -207,7 +205,6 @@ struct task_dependency {
  * @param tstype The MPI_Datatype to initialize
  */
 void task_dependency_define(MPI_Datatype *tstype) {
-
   /* Define the variables */
   const int count = 8;
   int blocklens[count];
@@ -256,17 +253,14 @@ void task_dependency_define(MPI_Datatype *tstype) {
  */
 void task_dependency_sum(void *in_p, void *out_p, int *len,
                          MPI_Datatype *type) {
-
   /* change pointer type */
   struct task_dependency *in = (struct task_dependency *)in_p;
   struct task_dependency *out = (struct task_dependency *)out_p;
 
   /* Loop over all the current objects */
   for (int i = 0; i < *len; i++) {
-
     /* loop over all the object set in invals */
     for (int j = 0; j < MAX_NUMBER_DEP; j++) {
-
       /* Have we reached the end of the links? */
       if (in[i].number_link[j] == -1) {
         break;
@@ -354,7 +348,6 @@ void task_dependency_sum(void *in_p, void *out_p, int *len,
  * @param verbose Are we verbose about this?
  */
 void scheduler_write_dependencies(struct scheduler *s, int verbose) {
-
   const ticks tic = getticks();
 
   /* Number of possible relations between tasks */
@@ -398,7 +391,6 @@ void scheduler_write_dependencies(struct scheduler *s, int verbose) {
 
       int k = 0;
       while (k < MAX_NUMBER_DEP) {
-
         /* not written yet */
         if (cur->number_link[k] == -1) {
           /* set tb */
@@ -542,7 +534,6 @@ void scheduler_write_dependencies(struct scheduler *s, int verbose) {
  * @param s The #scheduler we are working in.
  */
 static void scheduler_splittask_hydro(struct task *t, struct scheduler *s) {
-
   /* Are we considering both stars and hydro when splitting? */
   /* Note this is not very clean as the scheduler should not really
      access the engine... */
@@ -552,7 +543,6 @@ static void scheduler_splittask_hydro(struct task *t, struct scheduler *s) {
   /* Iterate on this task until we're done with it. */
   int redo = 1;
   while (redo) {
-
     /* Reset the redo flag. */
     redo = 0;
 
@@ -579,7 +569,6 @@ static void scheduler_splittask_hydro(struct task *t, struct scheduler *s) {
 
     /* Self-interaction? */
     if (t->type == task_type_self) {
-
       /* Get a handle on the cell involved. */
       struct cell *ci = t->ci;
 
@@ -591,16 +580,13 @@ static void scheduler_splittask_hydro(struct task *t, struct scheduler *s) {
 
       /* Is this cell even split and the task does not violate h ? */
       if (cell_can_split_self_hydro_task(ci)) {
-
         /* Make a sub? */
         if (scheduler_dosub && ci->hydro.count < space_subsize_self_hydro) {
-
           /* convert to a self-subtask. */
           t->type = task_type_sub_self;
 
           /* Otherwise, make tasks explicitly. */
         } else {
-
           /* Take a step back (we're going to recycle the current task)... */
           redo = 1;
 
@@ -609,12 +595,10 @@ static void scheduler_splittask_hydro(struct task *t, struct scheduler *s) {
           while (ci->progeny[first_child] == NULL) first_child++;
           t->ci = ci->progeny[first_child];
           for (int k = first_child + 1; k < 8; k++) {
-
             /* Do we have a non-empty progenitor? */
             if (ci->progeny[k] != NULL &&
                 (ci->progeny[k]->hydro.count ||
                  (with_feedback && ci->progeny[k]->stars.count))) {
-
               scheduler_splittask_hydro(
                   scheduler_addtask(s, task_type_self, t->subtype, 0, 0,
                                     ci->progeny[k], NULL),
@@ -624,19 +608,15 @@ static void scheduler_splittask_hydro(struct task *t, struct scheduler *s) {
 
           /* Make a task for each pair of progeny */
           for (int j = 0; j < 8; j++) {
-
             /* Do we have a non-empty progenitor? */
             if (ci->progeny[j] != NULL &&
                 (ci->progeny[j]->hydro.count ||
                  (with_feedback && ci->progeny[j]->stars.count))) {
-
               for (int k = j + 1; k < 8; k++) {
-
                 /* Do we have a second non-empty progenitor? */
                 if (ci->progeny[k] != NULL &&
                     (ci->progeny[k]->hydro.count ||
                      (with_feedback && ci->progeny[k]->stars.count))) {
-
                   scheduler_splittask_hydro(
                       scheduler_addtask(s, task_type_pair, t->subtype,
                                         sub_sid_flag[j][k], 0, ci->progeny[j],
@@ -654,7 +634,6 @@ static void scheduler_splittask_hydro(struct task *t, struct scheduler *s) {
 
     /* Pair interaction? */
     else if (t->type == task_type_pair) {
-
       /* Get a handle on the cells involved. */
       struct cell *ci = t->ci;
       struct cell *cj = t->cj;
@@ -679,361 +658,38 @@ static void scheduler_splittask_hydro(struct task *t, struct scheduler *s) {
       /* Should this task be split-up? */
       if (cell_can_split_pair_hydro_task(ci) &&
           cell_can_split_pair_hydro_task(cj)) {
-
         /* Replace by a single sub-task? */
         if (scheduler_dosub && /* Use division to avoid integer overflow. */
             ci->hydro.count * sid_scale[sid] <
                 space_subsize_pair_hydro / cj->hydro.count &&
             !sort_is_corner(sid)) {
-
           /* Make this task a sub task. */
           t->type = task_type_sub_pair;
 
           /* Otherwise, split it. */
         } else {
-
           /* Take a step back (we're going to recycle the current task)... */
           redo = 1;
 
-          /* For each different sorting type... */
-          switch (sid) {
-
-            case 0: /* (  1 ,  1 ,  1 ) */
-              t->ci = ci->progeny[7];
-              t->cj = cj->progeny[0];
-              t->flags = 0;
-              break;
-
-            case 1: /* (  1 ,  1 ,  0 ) */
-              t->ci = ci->progeny[6];
-              t->cj = cj->progeny[0];
-              t->flags = 1;
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 1, 0,
-                                    ci->progeny[7], cj->progeny[1]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 0, 0,
-                                    ci->progeny[6], cj->progeny[1]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 2, 0,
-                                    ci->progeny[7], cj->progeny[0]),
-                  s);
-              break;
-
-            case 2: /* (  1 ,  1 , -1 ) */
-              t->ci = ci->progeny[6];
-              t->cj = cj->progeny[1];
-              t->flags = 2;
-              break;
-
-            case 3: /* (  1 ,  0 ,  1 ) */
-              t->ci = ci->progeny[5];
-              t->cj = cj->progeny[0];
-              t->flags = 3;
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 3, 0,
-                                    ci->progeny[7], cj->progeny[2]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 0, 0,
-                                    ci->progeny[5], cj->progeny[2]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 6, 0,
-                                    ci->progeny[7], cj->progeny[0]),
-                  s);
-              break;
-
-            case 4: /* (  1 ,  0 ,  0 ) */
-              t->ci = ci->progeny[4];
-              t->cj = cj->progeny[0];
-              t->flags = 4;
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 5, 0,
-                                    ci->progeny[5], cj->progeny[0]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 7, 0,
-                                    ci->progeny[6], cj->progeny[0]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 8, 0,
-                                    ci->progeny[7], cj->progeny[0]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 3, 0,
-                                    ci->progeny[4], cj->progeny[1]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 4, 0,
-                                    ci->progeny[5], cj->progeny[1]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 6, 0,
-                                    ci->progeny[6], cj->progeny[1]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 7, 0,
-                                    ci->progeny[7], cj->progeny[1]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 1, 0,
-                                    ci->progeny[4], cj->progeny[2]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 2, 0,
-                                    ci->progeny[5], cj->progeny[2]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 4, 0,
-                                    ci->progeny[6], cj->progeny[2]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 5, 0,
-                                    ci->progeny[7], cj->progeny[2]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 0, 0,
-                                    ci->progeny[4], cj->progeny[3]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 1, 0,
-                                    ci->progeny[5], cj->progeny[3]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 3, 0,
-                                    ci->progeny[6], cj->progeny[3]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 4, 0,
-                                    ci->progeny[7], cj->progeny[3]),
-                  s);
-              break;
-
-            case 5: /* (  1 ,  0 , -1 ) */
-              t->ci = ci->progeny[4];
-              t->cj = cj->progeny[1];
-              t->flags = 5;
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 5, 0,
-                                    ci->progeny[6], cj->progeny[3]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 2, 0,
-                                    ci->progeny[4], cj->progeny[3]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 8, 0,
-                                    ci->progeny[6], cj->progeny[1]),
-                  s);
-              break;
-
-            case 6: /* (  1 , -1 ,  1 ) */
-              t->ci = ci->progeny[5];
-              t->cj = cj->progeny[2];
-              t->flags = 6;
-              break;
-
-            case 7: /* (  1 , -1 ,  0 ) */
-              t->ci = ci->progeny[4];
-              t->cj = cj->progeny[3];
-              t->flags = 6;
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 8, 0,
-                                    ci->progeny[5], cj->progeny[2]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 7, 0,
-                                    ci->progeny[4], cj->progeny[2]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 7, 0,
-                                    ci->progeny[5], cj->progeny[3]),
-                  s);
-              break;
-
-            case 8: /* (  1 , -1 , -1 ) */
-              t->ci = ci->progeny[4];
-              t->cj = cj->progeny[3];
-              t->flags = 8;
-              break;
-
-            case 9: /* (  0 ,  1 ,  1 ) */
-              t->ci = ci->progeny[3];
-              t->cj = cj->progeny[0];
-              t->flags = 9;
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 9, 0,
-                                    ci->progeny[7], cj->progeny[4]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 0, 0,
-                                    ci->progeny[3], cj->progeny[4]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 8, 0,
-                                    ci->progeny[7], cj->progeny[0]),
-                  s);
-              break;
-
-            case 10: /* (  0 ,  1 ,  0 ) */
-              t->ci = ci->progeny[2];
-              t->cj = cj->progeny[0];
-              t->flags = 10;
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 11, 0,
-                                    ci->progeny[3], cj->progeny[0]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 7, 0,
-                                    ci->progeny[6], cj->progeny[0]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 6, 0,
-                                    ci->progeny[7], cj->progeny[0]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 9, 0,
-                                    ci->progeny[2], cj->progeny[1]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 10, 0,
-                                    ci->progeny[3], cj->progeny[1]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 8, 0,
-                                    ci->progeny[6], cj->progeny[1]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 7, 0,
-                                    ci->progeny[7], cj->progeny[1]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 1, 0,
-                                    ci->progeny[2], cj->progeny[4]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 2, 0,
-                                    ci->progeny[3], cj->progeny[4]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 10, 0,
-                                    ci->progeny[6], cj->progeny[4]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 11, 0,
-                                    ci->progeny[7], cj->progeny[4]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 0, 0,
-                                    ci->progeny[2], cj->progeny[5]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 1, 0,
-                                    ci->progeny[3], cj->progeny[5]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 9, 0,
-                                    ci->progeny[6], cj->progeny[5]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 10, 0,
-                                    ci->progeny[7], cj->progeny[5]),
-                  s);
-              break;
-
-            case 11: /* (  0 ,  1 , -1 ) */
-              t->ci = ci->progeny[2];
-              t->cj = cj->progeny[1];
-              t->flags = 11;
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 11, 0,
-                                    ci->progeny[6], cj->progeny[5]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 2, 0,
-                                    ci->progeny[2], cj->progeny[5]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 6, 0,
-                                    ci->progeny[6], cj->progeny[1]),
-                  s);
-              break;
-
-            case 12: /* (  0 ,  0 ,  1 ) */
-              t->ci = ci->progeny[1];
-              t->cj = cj->progeny[0];
-              t->flags = 12;
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 11, 0,
-                                    ci->progeny[3], cj->progeny[0]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 5, 0,
-                                    ci->progeny[5], cj->progeny[0]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 2, 0,
-                                    ci->progeny[7], cj->progeny[0]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 9, 0,
-                                    ci->progeny[1], cj->progeny[2]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 12, 0,
-                                    ci->progeny[3], cj->progeny[2]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 8, 0,
-                                    ci->progeny[5], cj->progeny[2]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 5, 0,
-                                    ci->progeny[7], cj->progeny[2]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 3, 0,
-                                    ci->progeny[1], cj->progeny[4]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 6, 0,
-                                    ci->progeny[3], cj->progeny[4]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 12, 0,
-                                    ci->progeny[5], cj->progeny[4]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 11, 0,
-                                    ci->progeny[7], cj->progeny[4]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 0, 0,
-                                    ci->progeny[1], cj->progeny[6]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 3, 0,
-                                    ci->progeny[3], cj->progeny[6]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 9, 0,
-                                    ci->progeny[5], cj->progeny[6]),
-                  s);
-              scheduler_splittask_hydro(
-                  scheduler_addtask(s, task_type_pair, t->subtype, 12, 0,
-                                    ci->progeny[7], cj->progeny[6]),
-                  s);
-              break;
-          } /* switch(sid) */
+          /* Loop over the sub-cell pairs for the current sid and add new tasks
+           * for them. */
+          struct cell_split_pair *csp = &cell_split_pairs[sid];
+          t->ci = ci->progeny[csp->pairs[0].pid];
+          t->cj = cj->progeny[csp->pairs[0].pjd];
+          t->flags = csp->pairs[0].sid;
+          for (int k = 1; k < csp->count; k++) {
+            scheduler_splittask_hydro(
+                scheduler_addtask(s, task_type_pair, t->subtype,
+                                  csp->pairs[k].sid, 0,
+                                  ci->progeny[csp->pairs[k].pid],
+                                  cj->progeny[csp->pairs[k].pjd]),
+                s);
+          }
         }
 
         /* Otherwise, break it up if it is too large? */
       } else if (scheduler_doforcesplit && ci->split && cj->split &&
                  (ci->hydro.count > space_maxsize / cj->hydro.count)) {
-
         // message( "force splitting pair with %i and %i parts." ,
         // ci->hydro.count , cj->hydro.count );
 
@@ -1062,14 +718,12 @@ static void scheduler_splittask_hydro(struct task *t, struct scheduler *s) {
  * @param s The #scheduler we are working in.
  */
 static void scheduler_splittask_gravity(struct task *t, struct scheduler *s) {
-
   const struct space *sp = s->space;
   struct engine *e = sp->e;
 
   /* Iterate on this task until we're done with it. */
   int redo = 1;
   while (redo) {
-
     /* Reset the redo flag. */
     redo = 0;
 
@@ -1084,7 +738,6 @@ static void scheduler_splittask_gravity(struct task *t, struct scheduler *s) {
 
     /* Self-interaction? */
     if (t->type == task_type_self) {
-
       /* Get a handle on the cell involved. */
       const struct cell *ci = t->ci;
 
@@ -1096,12 +749,9 @@ static void scheduler_splittask_gravity(struct task *t, struct scheduler *s) {
 
       /* Should we split this task? */
       if (cell_can_split_self_gravity_task(ci)) {
-
         if (scheduler_dosub && ci->grav.count < space_subsize_self_grav) {
-
           /* Otherwise, split it. */
         } else {
-
           /* Take a step back (we're going to recycle the current task)... */
           redo = 1;
 
@@ -1136,7 +786,6 @@ static void scheduler_splittask_gravity(struct task *t, struct scheduler *s) {
 
     /* Pair interaction? */
     else if (t->type == task_type_pair) {
-
       /* Get a handle on the cells involved. */
       struct cell *ci = t->ci;
       struct cell *cj = t->cj;
@@ -1150,17 +799,14 @@ static void scheduler_splittask_gravity(struct task *t, struct scheduler *s) {
       /* Should this task be split-up? */
       if (cell_can_split_pair_gravity_task(ci) &&
           cell_can_split_pair_gravity_task(cj)) {
-
         const long long gcount_i = ci->grav.count;
         const long long gcount_j = cj->grav.count;
 
         /* Replace by a single sub-task? */
         if (scheduler_dosub &&
             gcount_i * gcount_j < ((long long)space_subsize_pair_grav)) {
-
           /* Otherwise, split it. */
         } else {
-
           /* Turn the task into a M-M task that will take care of all the
            * progeny pairs */
           t->type = task_type_grav_mm;
@@ -1172,11 +818,9 @@ static void scheduler_splittask_gravity(struct task *t, struct scheduler *s) {
             if (ci->progeny[i] != NULL) {
               for (int j = 0; j < 8; j++) {
                 if (cj->progeny[j] != NULL) {
-
                   /* Can we use a M-M interaction here? */
                   if (cell_can_use_pair_mm_rebuild(ci->progeny[i],
                                                    cj->progeny[j], e, sp)) {
-
                     /* Flag this pair as being treated by the M-M task.
                      * We use the 64 bits in the task->flags field to store
                      * this information. The corresponding taks will unpack
@@ -1186,7 +830,6 @@ static void scheduler_splittask_gravity(struct task *t, struct scheduler *s) {
                     t->flags |= (1ULL << flag);
 
                   } else {
-
                     /* Ok, we actually have to create a task */
                     scheduler_splittask_gravity(
                         scheduler_addtask(s, task_type_pair, task_subtype_grav,
@@ -1222,7 +865,6 @@ static void scheduler_splittask_gravity(struct task *t, struct scheduler *s) {
  */
 void scheduler_splittasks_mapper(void *map_data, int num_elements,
                                  void *extra_data) {
-
   /* Extract the parameters. */
   struct scheduler *s = (struct scheduler *)extra_data;
   struct task *tasks = (struct task *)map_data;
@@ -1253,7 +895,6 @@ void scheduler_splittasks_mapper(void *map_data, int num_elements,
  * @param s The #scheduler.
  */
 void scheduler_splittasks(struct scheduler *s) {
-
   /* Call the mapper on each current task. */
   threadpool_map(s->threadpool, scheduler_splittasks_mapper, s->tasks,
                  s->nr_tasks, sizeof(struct task), 0, s);
@@ -1274,7 +915,6 @@ void scheduler_splittasks(struct scheduler *s) {
 struct task *scheduler_addtask(struct scheduler *s, enum task_types type,
                                enum task_subtypes subtype, int flags,
                                int implicit, struct cell *ci, struct cell *cj) {
-
   /* Get the next free task. */
   const int ind = atomic_inc(&s->tasks_next);
 
@@ -1321,7 +961,6 @@ struct task *scheduler_addtask(struct scheduler *s, enum task_types type,
  * @param s The #scheduler.
  */
 void scheduler_set_unlocks(struct scheduler *s) {
-
   /* Store the counts for each task. */
   short int *counts;
   if ((counts = (short int *)swift_malloc(
@@ -1410,7 +1049,6 @@ void scheduler_set_unlocks(struct scheduler *s) {
  * @param s The #scheduler.
  */
 void scheduler_ranktasks(struct scheduler *s) {
-
   struct task *tasks = s->tasks;
   int *tid = s->tasks_ind;
   const int nr_tasks = s->nr_tasks;
@@ -1435,7 +1073,6 @@ void scheduler_ranktasks(struct scheduler *s) {
 
   /* Main loop. */
   for (int j = 0, rank = 0; j < nr_tasks; rank++) {
-
     /* Did we get anything? */
     if (j == left) error("Unsatisfiable task dependencies detected.");
 
@@ -1475,10 +1112,8 @@ void scheduler_ranktasks(struct scheduler *s) {
  * @param size The maximum number of tasks in the #scheduler.
  */
 void scheduler_reset(struct scheduler *s, int size) {
-
   /* Do we need to re-allocate? */
   if (size > s->size) {
-
     /* Free existing task lists if necessary. */
     scheduler_free_tasks(s);
 
@@ -1516,7 +1151,6 @@ void scheduler_reset(struct scheduler *s, int size) {
  * @param verbose Are we talkative?
  */
 void scheduler_reweight(struct scheduler *s, int verbose) {
-
   const int nr_tasks = s->nr_tasks;
   int *tid = s->tasks_ind;
   struct task *tasks = s->tasks;
@@ -1709,7 +1343,6 @@ void scheduler_reweight(struct scheduler *s, int verbose) {
  */
 void scheduler_rewait_mapper(void *map_data, int num_elements,
                              void *extra_data) {
-
   struct scheduler *s = (struct scheduler *)extra_data;
   const int *tid = (int *)map_data;
 
@@ -1758,7 +1391,6 @@ void scheduler_enqueue_mapper(void *map_data, int num_elements,
  * @param s The #scheduler.
  */
 void scheduler_start(struct scheduler *s) {
-
   /* Reset all task timers. */
   for (int i = 0; i < s->nr_tasks; ++i) {
     s->tasks[i].tic = 0;
@@ -1800,7 +1432,6 @@ void scheduler_start(struct scheduler *s) {
  * @param t The #task.
  */
 void scheduler_enqueue(struct scheduler *s, struct task *t) {
-
   /* The target queue for this task. */
   int qid = -1;
 
@@ -2074,7 +1705,6 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) {
  *         been identified.
  */
 struct task *scheduler_done(struct scheduler *s, struct task *t) {
-
   /* Release whatever locks this task held. */
   if (!t->implicit) task_unlock(t);
 
@@ -2120,7 +1750,6 @@ struct task *scheduler_done(struct scheduler *s, struct task *t) {
  *         been identified.
  */
 struct task *scheduler_unlock(struct scheduler *s, struct task *t) {
-
   /* Loop through the dependencies and add them to a queue if
      they are ready. */
   for (int k = 0; k < t->nr_unlock_tasks; k++) {
@@ -2159,7 +1788,6 @@ struct task *scheduler_unlock(struct scheduler *s, struct task *t) {
  */
 struct task *scheduler_gettask(struct scheduler *s, int qid,
                                const struct task *prev) {
-
   struct task *res = NULL;
   const int nr_queues = s->nr_queues;
   unsigned int seed = qid;
@@ -2169,11 +1797,9 @@ struct task *scheduler_gettask(struct scheduler *s, int qid,
 
   /* Loop as long as there are tasks... */
   while (s->waiting > 0 && res == NULL) {
-
     /* Try more than once before sleeping. */
     for (int tries = 0; res == NULL && s->waiting && tries < scheduler_maxtries;
          tries++) {
-
       /* Try to get a task from the suggested queue. */
       if (s->queues[qid].count > 0 || s->queues[qid].count_incoming > 0) {
         TIMER_TIC
@@ -2245,7 +1871,6 @@ struct task *scheduler_gettask(struct scheduler *s, int qid,
 void scheduler_init(struct scheduler *s, struct space *space, int nr_tasks,
                     int nr_queues, unsigned int flags, int nodeID,
                     struct threadpool *tp) {
-
   /* Init the lock. */
   lock_init(&s->lock);
 
@@ -2294,7 +1919,6 @@ void scheduler_init(struct scheduler *s, struct space *space, int nr_tasks,
  * @param fileName Name of the file to write to
  */
 void scheduler_print_tasks(const struct scheduler *s, const char *fileName) {
-
   const int nr_tasks = s->nr_tasks, *tid = s->tasks_ind;
   struct task *t, *tasks = s->tasks;
 
@@ -2316,7 +1940,6 @@ void scheduler_print_tasks(const struct scheduler *s, const char *fileName) {
  * @brief Frees up the memory allocated for this #scheduler
  */
 void scheduler_clean(struct scheduler *s) {
-
   scheduler_free_tasks(s);
   swift_free("unlocks", s->unlocks);
   swift_free("unlock_ind", s->unlock_ind);
@@ -2328,7 +1951,6 @@ void scheduler_clean(struct scheduler *s) {
  * @brief Free the task arrays allocated by this #scheduler.
  */
 void scheduler_free_tasks(struct scheduler *s) {
-
   if (s->tasks != NULL) {
     swift_free("tasks", s->tasks);
     s->tasks = NULL;
@@ -2364,7 +1986,6 @@ void scheduler_write_task_level(const struct scheduler *s) {
   for (int i = 0; i < nr_tasks; i++) {
     const struct task *t = &tasks[i];
     if (t->ci) {
-
       if ((int)t->ci->depth >= max_depth)
         error("Cell is too deep, you need to increase max_depth");