diff --git a/src/engine.c b/src/engine.c
index 5020a43159344fe23cb84c9f6ec56111e68c17b6..cbf0d36d5c7a33cf520f1de6ae6a8b86a9de4180 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -4200,10 +4200,10 @@ void engine_init_particles(struct engine *e, int flag_entropy_ICs,
 
   message("Performing Friends Of Friends search.");
 
-  const double l_x = 0.2 * (s->dim[0] / pow(s->nr_gparts, 1. / 3.));
-  const double l_x2 = l_x * l_x;
-  s->l_x = l_x;
-  s->l_x2 = l_x2;
+  /* Calculate the particle linking length based upon the mean inter-particle spacing. */
+  const int total_nr_dmparts = e->total_nr_gparts - e->total_nr_parts;
+  const double l_x = 0.2 * (s->dim[0] / cbrt(total_nr_dmparts));
+  s->l_x2 = l_x * l_x;
 
   ticks tic = getticks();
   fof_search_serial(s);
diff --git a/src/gravity/Default/gravity_part.h b/src/gravity/Default/gravity_part.h
index ef93488f0b788064e2f897ae9c84f05c371b0e12..d6bbc24b8d0affaf0b44d095794e8f3bb93fe132 100644
--- a/src/gravity/Default/gravity_part.h
+++ b/src/gravity/Default/gravity_part.h
@@ -50,6 +50,7 @@ struct gpart {
   /*! Type of the #gpart (DM, gas, star, ...) */
   enum part_type type;
 
+  /*! Particle offset into FOF group id array. */
   size_t offset;
 
 #ifdef SWIFT_DEBUG_CHECKS
diff --git a/src/space.h b/src/space.h
index 18cf089845e3d71ebacb6500f1834a521f5046c7..23f01fedbffe9959a1338fa5bc90624c706226e6 100644
--- a/src/space.h
+++ b/src/space.h
@@ -155,15 +155,9 @@ struct space {
   /*! The associated engine. */
   struct engine *e;
 
-  /*! The FOF linking length. */
-  double l_x;
-
   /*! The FOF linking length squared. */
   double l_x2;
 
-  /*! The cell search radius squared for FOF. */
-  double cell_search_r2;
-
 #ifdef WITH_MPI
 
   /*! Buffers for parts that we will receive from foreign cells. */