diff --git a/src/cell_unskip.c b/src/cell_unskip.c
index f8f448ff9f27a558a668167212ee3ed5f0940fa6..e85534abe2d934348918b2de22a3c25cc2f0619f 100644
--- a/src/cell_unskip.c
+++ b/src/cell_unskip.c
@@ -847,7 +847,7 @@ void cell_activate_subcell_hydro_tasks(struct cell *ci, struct cell *cj,
 
     /* Get the orientation of the pair. */
     double shift[3];
-    const int sid = space_getsid(s->space, &ci, &cj, shift);
+    const int sid = space_getsid_and_swap_cells(s->space, &ci, &cj, shift);
 
     /* recurse? */
     if (cell_can_recurse_in_pair_hydro_task(ci) &&
@@ -959,7 +959,7 @@ void cell_activate_subcell_stars_tasks(struct cell *ci, struct cell *cj,
 
     /* Get the orientation of the pair. */
     double shift[3];
-    const int sid = space_getsid(s->space, &ci, &cj, shift);
+    const int sid = space_getsid_and_swap_cells(s->space, &ci, &cj, shift);
 
     const int ci_active = cell_need_activating_stars(ci, e, with_star_formation,
                                                      with_star_formation_sink);
@@ -1090,7 +1090,7 @@ void cell_activate_subcell_black_holes_tasks(struct cell *ci, struct cell *cj,
 
     /* Get the orientation of the pair. */
     double shift[3];
-    const int sid = space_getsid(s->space, &ci, &cj, shift);
+    const int sid = space_getsid_and_swap_cells(s->space, &ci, &cj, shift);
 
     const int ci_active = cell_is_active_black_holes(ci, e);
     const int cj_active = cell_is_active_black_holes(cj, e);
@@ -1197,7 +1197,7 @@ void cell_activate_subcell_sinks_tasks(struct cell *ci, struct cell *cj,
   else {
     /* Get the orientation of the pair. */
     double shift[3];
-    const int sid = space_getsid(s->space, &ci, &cj, shift);
+    const int sid = space_getsid_and_swap_cells(s->space, &ci, &cj, shift);
 
     const int ci_active =
         cell_is_active_sinks(ci, e) || cell_is_active_hydro(ci, e);
@@ -1586,7 +1586,7 @@ void cell_activate_subcell_rt_tasks(struct cell *ci, struct cell *cj,
 
     /* Get the orientation of the pair. */
     double shift[3];
-    const int sid = space_getsid(s->space, &ci, &cj, shift);
+    const int sid = space_getsid_and_swap_cells(s->space, &ci, &cj, shift);
 
     /* recurse? */
     if (cell_can_recurse_in_pair_hydro_task(ci) &&
diff --git a/src/runner_doiact_functions_black_holes.h b/src/runner_doiact_functions_black_holes.h
index 55e63e928b2a8f849061933700e2c3c17d4c5fcc..09ef41e8522baf4b033426d15f77234b3de59bec 100644
--- a/src/runner_doiact_functions_black_holes.h
+++ b/src/runner_doiact_functions_black_holes.h
@@ -667,7 +667,7 @@ void DOSUB_SUBSET_BH(struct runner *r, struct cell *ci, struct bpart *bparts,
 
       /* Get the type of pair and flip ci/cj if needed. */
       double shift[3] = {0.0, 0.0, 0.0};
-      const int sid = space_getsid(s, &ci, &cj, shift);
+      const int sid = space_getsid_and_swap_cells(s, &ci, &cj, shift);
 
       struct cell_split_pair *csp = &cell_split_pairs[sid];
       for (int k = 0; k < csp->count; k++) {
@@ -813,7 +813,7 @@ void DOSUB_PAIR1_BH(struct runner *r, struct cell *ci, struct cell *cj,
 
   /* Get the type of pair and flip ci/cj if needed. */
   double shift[3];
-  const int sid = space_getsid(s, &ci, &cj, shift);
+  const int sid = space_getsid_and_swap_cells(s, &ci, &cj, shift);
 
   /* Recurse? */
   if (cell_can_recurse_in_pair_black_holes_task(ci, cj) &&
diff --git a/src/runner_doiact_functions_hydro.h b/src/runner_doiact_functions_hydro.h
index 068c6d3be282f89e3c8e8cd0d0739908f7eccac0..eff6702b82e0007e28157864c93a93b435619960 100644
--- a/src/runner_doiact_functions_hydro.h
+++ b/src/runner_doiact_functions_hydro.h
@@ -1350,7 +1350,7 @@ void DOPAIR1_BRANCH(struct runner *r, struct cell *ci, struct cell *cj) {
 
   /* Get the sort ID. */
   double shift[3] = {0.0, 0.0, 0.0};
-  const int sid = space_getsid(e->s, &ci, &cj, shift);
+  const int sid = space_getsid_and_swap_cells(e->s, &ci, &cj, shift);
 
   /* Have the cells been sorted? */
   if (!(ci->hydro.sorted & (1 << sid)) ||
@@ -1995,7 +1995,7 @@ void DOPAIR2_BRANCH(struct runner *r, struct cell *ci, struct cell *cj) {
 
   /* Get the sort ID. */
   double shift[3] = {0.0, 0.0, 0.0};
-  const int sid = space_getsid(e->s, &ci, &cj, shift);
+  const int sid = space_getsid_and_swap_cells(e->s, &ci, &cj, shift);
 
   /* Have the cells been sorted? */
   if (!(ci->hydro.sorted & (1 << sid)) ||
@@ -2549,7 +2549,7 @@ void DOSUB_PAIR1(struct runner *r, struct cell *ci, struct cell *cj,
 
   /* Get the type of pair and flip ci/cj if needed. */
   double shift[3];
-  const int sid = space_getsid(s, &ci, &cj, shift);
+  const int sid = space_getsid_and_swap_cells(s, &ci, &cj, shift);
 
   /* Recurse? */
   if (cell_can_recurse_in_pair_hydro_task(ci) &&
@@ -2655,7 +2655,7 @@ void DOSUB_PAIR2(struct runner *r, struct cell *ci, struct cell *cj,
 
   /* Get the type of pair and flip ci/cj if needed. */
   double shift[3];
-  const int sid = space_getsid(s, &ci, &cj, shift);
+  const int sid = space_getsid_and_swap_cells(s, &ci, &cj, shift);
 
   /* Recurse? */
   if (cell_can_recurse_in_pair_hydro_task(ci) &&
@@ -2789,7 +2789,7 @@ void DOSUB_SUBSET(struct runner *r, struct cell *ci, struct part *parts,
 
       /* Get the type of pair and flip ci/cj if needed. */
       double shift[3] = {0.0, 0.0, 0.0};
-      const int sid = space_getsid(s, &ci, &cj, shift);
+      const int sid = space_getsid_and_swap_cells(s, &ci, &cj, shift);
 
       struct cell_split_pair *csp = &cell_split_pairs[sid];
       for (int k = 0; k < csp->count; k++) {
diff --git a/src/runner_doiact_functions_limiter.h b/src/runner_doiact_functions_limiter.h
index ee60c7d322457f0abe4044cf8bb2bdd5e115c0ea..44f6572b42dbf15b71b65ad3b1db9d60d6c63f83 100644
--- a/src/runner_doiact_functions_limiter.h
+++ b/src/runner_doiact_functions_limiter.h
@@ -470,7 +470,7 @@ void DOPAIR1_BRANCH(struct runner *r, struct cell *ci, struct cell *cj) {
 
   /* Get the sort ID. */
   double shift[3] = {0.0, 0.0, 0.0};
-  const int sid = space_getsid(e->s, &ci, &cj, shift);
+  const int sid = space_getsid_and_swap_cells(e->s, &ci, &cj, shift);
 
   /* Have the cells been sorted? */
   if (!(ci->hydro.sorted & (1 << sid)) ||
@@ -730,7 +730,7 @@ void DOSUB_PAIR1(struct runner *r, struct cell *ci, struct cell *cj,
 
   /* Get the type of pair and flip ci/cj if needed. */
   double shift[3];
-  const int sid = space_getsid(s, &ci, &cj, shift);
+  const int sid = space_getsid_and_swap_cells(s, &ci, &cj, shift);
 
   /* Should we even bother? */
   const int do_i = cell_get_flag(ci, cell_flag_do_hydro_limiter);
diff --git a/src/runner_doiact_functions_stars.h b/src/runner_doiact_functions_stars.h
index b163c6fc8a290c93238960e68dbb142283c49003..c09811da106d89746e332f159e03d04910183e34 100644
--- a/src/runner_doiact_functions_stars.h
+++ b/src/runner_doiact_functions_stars.h
@@ -1131,7 +1131,7 @@ void DOSUB_SUBSET_STARS(struct runner *r, struct cell *ci, struct spart *sparts,
 
       /* Get the type of pair and flip ci/cj if needed. */
       double shift[3] = {0.0, 0.0, 0.0};
-      const int sid = space_getsid(s, &ci, &cj, shift);
+      const int sid = space_getsid_and_swap_cells(s, &ci, &cj, shift);
 
       struct cell_split_pair *csp = &cell_split_pairs[sid];
       for (int k = 0; k < csp->count; k++) {
@@ -1232,7 +1232,7 @@ void DOPAIR1_BRANCH_STARS(struct runner *r, struct cell *ci, struct cell *cj) {
 
   /* Get the sort ID. */
   double shift[3] = {0.0, 0.0, 0.0};
-  const int sid = space_getsid(e->s, &ci, &cj, shift);
+  const int sid = space_getsid_and_swap_cells(e->s, &ci, &cj, shift);
 
   const int ci_active = cell_is_active_stars(ci, e);
   const int cj_active = cell_is_active_stars(cj, e);
@@ -1329,7 +1329,7 @@ void DOSUB_PAIR1_STARS(struct runner *r, struct cell *ci, struct cell *cj,
 
   /* Get the type of pair and flip ci/cj if needed. */
   double shift[3];
-  const int sid = space_getsid(s, &ci, &cj, shift);
+  const int sid = space_getsid_and_swap_cells(s, &ci, &cj, shift);
 
   /* Recurse? */
   if (cell_can_recurse_in_pair_stars_task(ci, cj) &&
diff --git a/src/runner_doiact_nosort.h b/src/runner_doiact_nosort.h
index 6a442afbdb0c7dfb24c5e9cb386783746a1f05ed..4b500fe2e6ed9da97979623313cc205775af6d6c 100644
--- a/src/runner_doiact_nosort.h
+++ b/src/runner_doiact_nosort.h
@@ -20,7 +20,7 @@ void DOPAIR1_NOSORT(struct runner *r, struct cell *ci, struct cell *cj) {
 
   /* Get the relative distance between the pairs, wrapping. */
   double shift[3] = {0.0, 0.0, 0.0};
-  space_getsid(e->s, &ci, &cj, shift);
+  space_getsid_and_swap_cells(e->s, &ci, &cj, shift);
 
   const int count_i = ci->count;
   const int count_j = cj->count;
@@ -145,7 +145,7 @@ void DOPAIR2_NOSORT(struct runner *r, struct cell *ci, struct cell *cj) {
 
   /* Get the relative distance between the pairs, wrapping. */
   double shift[3] = {0.0, 0.0, 0.0};
-  space_getsid(e->s, &ci, &cj, shift);
+  space_getsid_and_swap_cells(e->s, &ci, &cj, shift);
 
   const int count_i = ci->count;
   const int count_j = cj->count;
diff --git a/src/runner_main.c b/src/runner_main.c
index 66a0074b9d917c6c8c2f455ad68aef18c1853d31..1e7a5975853290a2c525610087c7ce9888bb0c52 100644
--- a/src/runner_main.c
+++ b/src/runner_main.c
@@ -177,7 +177,7 @@ void *runner_main(void *data) {
         struct cell *ci_temp = ci;
         struct cell *cj_temp = cj;
         double shift[3];
-        t->sid = space_getsid(e->s, &ci_temp, &cj_temp, shift);
+        t->sid = space_getsid_and_swap_cells(e->s, &ci_temp, &cj_temp, shift);
       } else {
         t->sid = -1;
       }
diff --git a/src/runner_sinks.c b/src/runner_sinks.c
index 750d8d8561f2b42a266ab4365e36a63e8345d37c..cd9fd0c4cca70591b58685257704a4ca4278bbe2 100644
--- a/src/runner_sinks.c
+++ b/src/runner_sinks.c
@@ -418,7 +418,7 @@ void runner_dosub_pair_sinks_swallow(struct runner *r, struct cell *ci,
 
   /* Get the type of pair and flip ci/cj if needed. */
   double shift[3];
-  const int sid = space_getsid(s, &ci, &cj, shift);
+  const int sid = space_getsid_and_swap_cells(s, &ci, &cj, shift);
 
   /* Recurse? */
   if (cell_can_recurse_in_pair_sinks_task(ci, cj) &&
diff --git a/src/scheduler.c b/src/scheduler.c
index 6a9fb140c1f24a66cd029330dc94cffc67ea40b0..980f83c86ba71866f6fd73d28b8bc6d63638b69e 100644
--- a/src/scheduler.c
+++ b/src/scheduler.c
@@ -1281,10 +1281,10 @@ static void scheduler_splittask_hydro(struct task *t, struct scheduler *s) {
         break;
       }
 
-      /* Get the sort ID, use space_getsid and not t->flags
+      /* Get the sort ID, use space_getsid_and_swap_cells and not t->flags
          to make sure we get ci and cj swapped if needed. */
       double shift[3];
-      const int sid = space_getsid(s->space, &ci, &cj, shift);
+      const int sid = space_getsid_and_swap_cells(s->space, &ci, &cj, shift);
 
 #ifdef SWIFT_DEBUG_CHECKS
       if (sid != t->flags)
@@ -1374,7 +1374,7 @@ static void scheduler_splittask_hydro(struct task *t, struct scheduler *s) {
                     scheduler_addtask(s, task_type_pair, t->subtype, 0, 0,
                                       ci->progeny[j], cj->progeny[k]);
                 scheduler_splittask_hydro(tl, s);
-                tl->flags = space_getsid(s->space, &t->ci, &t->cj, shift);
+                tl->flags = space_getsid_and_swap_cells(s->space, &t->ci, &t->cj, shift);
               }
       }
     } /* pair interaction? */
diff --git a/src/space_getsid.h b/src/space_getsid.h
index 2124e2e1f027c54248d084c0c35da8a19d9efe66..40cdc1c911d1f7dc6b6c15e9caf60699041e633f 100644
--- a/src/space_getsid.h
+++ b/src/space_getsid.h
@@ -43,7 +43,7 @@
  *
  * @return The shift ID and set shift, may or may not swap ci and cj.
  */
-__attribute__((always_inline, nonnull)) INLINE static int space_getsid(
+__attribute__((always_inline, nonnull)) INLINE static int space_getsid_and_swap_cells(
     const struct space *s, struct cell **ci, struct cell **cj,
     double shift[3]) {