diff --git a/src/cell.c b/src/cell.c
index 9861a02684ea110a0dff0ff47c2e57401c6ad650..caaa4713dbf1311ca11f8b6d3aac65f0e22dfb6f 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -3619,7 +3619,7 @@ void cell_drift_gpart(struct cell *c, const struct engine *e, int force) {
     } else {
       dt_drift = (ti_current - ti_old_gpart) * e->time_base;
     }
-      
+
     /* 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++) {
diff --git a/src/engine.c b/src/engine.c
index 4b09ac8bb7dba43cc6f073d4a8e87ff92cb39082..964c43cd57209a674ee5afb86cd97a752f1cdd36 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -5109,7 +5109,7 @@ void engine_recompute_displacement_constraint(struct engine *e) {
 
   /* Mesh forces smoothing scale */
   float r_s;
-  if ((e->policy & engine_policy_self_gravity) && e->s->periodic == 1)
+  if ((e->policy & engine_policy_self_gravity) && e->s->periodic)
     r_s = e->mesh->r_s;
   else
     r_s = FLT_MAX;
diff --git a/src/engine_maketasks.c b/src/engine_maketasks.c
index f280c2a6106d9da59e58f79d9acb9e8e199040b4..4dd9e8a968c3225d733ee588a113033dc82fdcf0 100644
--- a/src/engine_maketasks.c
+++ b/src/engine_maketasks.c
@@ -1758,6 +1758,7 @@ void engine_make_starsloop_tasks_mapper(void *map_data, int num_elements,
 
   /* Extract the engine pointer. */
   struct engine *e = (struct engine *)extra_data;
+  const int periodic = e->s->periodic;
 
   struct space *s = e->s;
   struct scheduler *sched = &e->sched;
@@ -1789,15 +1790,15 @@ void engine_make_starsloop_tasks_mapper(void *map_data, int num_elements,
     /* Now loop over all the neighbours of this cell */
     for (int ii = -1; ii < 2; ii++) {
       int iii = i + ii;
-      if (!s->periodic && (iii < 0 || iii >= cdim[0])) continue;
+      if (periodic && (iii < 0 || iii >= cdim[0])) continue;
       iii = (iii + cdim[0]) % cdim[0];
       for (int jj = -1; jj < 2; jj++) {
         int jjj = j + jj;
-        if (!s->periodic && (jjj < 0 || jjj >= cdim[1])) continue;
+        if (periodic && (jjj < 0 || jjj >= cdim[1])) continue;
         jjj = (jjj + cdim[1]) % cdim[1];
         for (int kk = -1; kk < 2; kk++) {
           int kkk = k + kk;
-          if (!s->periodic && (kkk < 0 || kkk >= cdim[2])) continue;
+          if (periodic && (kkk < 0 || kkk >= cdim[2])) continue;
           kkk = (kkk + cdim[2]) % cdim[2];
 
           /* Get the neighbouring cell */
@@ -1837,6 +1838,7 @@ void engine_make_hydroloop_tasks_mapper(void *map_data, int num_elements,
 
   /* Extract the engine pointer. */
   struct engine *e = (struct engine *)extra_data;
+  const int periodic = e->s->periodic;
 
   struct space *s = e->s;
   struct scheduler *sched = &e->sched;
@@ -1870,15 +1872,15 @@ void engine_make_hydroloop_tasks_mapper(void *map_data, int num_elements,
     /* Now loop over all the neighbours of this cell */
     for (int ii = -1; ii < 2; ii++) {
       int iii = i + ii;
-      if (!s->periodic && (iii < 0 || iii >= cdim[0])) continue;
+      if (periodic && (iii < 0 || iii >= cdim[0])) continue;
       iii = (iii + cdim[0]) % cdim[0];
       for (int jj = -1; jj < 2; jj++) {
         int jjj = j + jj;
-        if (!s->periodic && (jjj < 0 || jjj >= cdim[1])) continue;
+        if (periodic && (jjj < 0 || jjj >= cdim[1])) continue;
         jjj = (jjj + cdim[1]) % cdim[1];
         for (int kk = -1; kk < 2; kk++) {
           int kkk = k + kk;
-          if (!s->periodic && (kkk < 0 || kkk >= cdim[2])) continue;
+          if (periodic && (kkk < 0 || kkk >= cdim[2])) continue;
           kkk = (kkk + cdim[2]) % cdim[2];
 
           /* Get the neighbouring cell */
diff --git a/src/logger_io.c b/src/logger_io.c
index a0a5ba1db85aa4eb96ee140966a47393ba5a3b68..3cef3497b2912411cea6763f5418bc76a7f5ece0 100644
--- a/src/logger_io.c
+++ b/src/logger_io.c
@@ -78,7 +78,7 @@ void write_index_single(struct engine* e, const char* baseName,
   const size_t Ngas = e->s->nr_parts;
   const size_t Nstars = e->s->nr_sparts;
   const size_t Ntot = e->s->nr_gparts;
-  int periodic = e->s->periodic;
+  const int periodic = e->s->periodic;
   int numFiles = 1;
   struct part* parts = e->s->parts;
   struct xpart* xparts = e->s->xparts;