diff --git a/examples/main.c b/examples/main.c
index 0c68ace030ff9745270923e9ef91dee95114609b..768640afe54f82cdd8208efeb1d13690e8e2c5e3 100644
--- a/examples/main.c
+++ b/examples/main.c
@@ -941,7 +941,7 @@ int main(int argc, char *argv[]) {
                   talking, restart_file);
 
     /* Initialise the FOF parameters. */
-    if (with_fof) fof_init(&s, N_total[0], N_total[1]);
+    if (with_fof) fof_init(&s, N_total[0], N_total[1], N_total[2]);
     
     if (myrank == 0) {
       clocks_gettime(&toc);
diff --git a/examples/main_fof.c b/examples/main_fof.c
index b8a44227c51675e7221027e56fb9e7bec060784b..2ddc1f24a6d02a70102a06b7e21fe7cb97125120 100644
--- a/examples/main_fof.c
+++ b/examples/main_fof.c
@@ -936,7 +936,7 @@ int main(int argc, char *argv[]) {
                   talking, restart_file);
 
     /* Initialise the FOF parameters. */
-    fof_init(&s, N_total[0], N_total[1]);
+    fof_init(&s, N_total[0], N_total[1], N_total[2]);
     
     if (myrank == 0) {
       clocks_gettime(&toc);
diff --git a/src/fof.c b/src/fof.c
index 75236cdf501ab10d1d41d4cf72c26dca607ace20..d23b3c1d9156cdfa9e1861829e445863092f26ae 100644
--- a/src/fof.c
+++ b/src/fof.c
@@ -46,7 +46,7 @@ MPI_Datatype group_length_mpi_type;
 size_t node_offset;
 
 /* Initialises parameters for the FOF search. */
-void fof_init(struct space *s, long long Ngas, long long Ngparts) {
+void fof_init(struct space *s, long long Ngas, long long Ngparts, long long Nstars) {
 
   struct engine *e = s->e;
 
@@ -78,7 +78,7 @@ void fof_init(struct space *s, long long Ngas, long long Ngparts) {
 
   /* Calculate the particle linking length based upon the mean inter-particle
    * spacing of the DM particles. */
-  const int total_nr_dmparts = Ngparts - Ngas;
+  const long long total_nr_dmparts = Ngparts - Ngas - Nstars;
   double l_x = l_x_scale * (s->dim[0] / cbrt(total_nr_dmparts));
 
   l_x = parser_get_opt_param_double(e->parameter_file, "FOF:absolute_linking_length", l_x);
diff --git a/src/fof.h b/src/fof.h
index ba445d2cf6489287ec211445cefa43953bf4b30f..3061c6a14dbb2844815be9d44cac8d4497f77f7f 100644
--- a/src/fof.h
+++ b/src/fof.h
@@ -62,7 +62,7 @@ struct cell_pair_indices {
 } SWIFT_STRUCT_ALIGN;
 
 /* Function prototypes. */
-void fof_init(struct space *s, long long Ngas, long long Ngparts);
+void fof_init(struct space *s, long long Ngas, long long Ngparts, long long Nstars);
 void fof_search_cell(struct space *s, struct cell *c);
 void fof_search_pair_cells(struct space *s, struct cell *ci, struct cell *cj);
 void fof_search_pair_cells_foreign(struct space *s, struct cell *ci, struct cell *cj, int *link_count, struct fof_mpi **group_links, int *group_links_size);