diff --git a/examples/main_fof.c b/examples/main_fof.c
index bde77ba0e5bf6289d245047554859620300751cc..d2c9a9be4c35b725863c7b10afc1a12b8af6d608 100644
--- a/examples/main_fof.c
+++ b/examples/main_fof.c
@@ -1018,7 +1018,7 @@ int main(int argc, char *argv[]) {
 #endif
 
     /* Perform first FOF search after the first snapshot dump. */
-    fof_search_tree(&s);
+    engine_fof(&e);
 
 #ifdef WITH_MPI
     MPI_Barrier(MPI_COMM_WORLD);
diff --git a/src/engine.c b/src/engine.c
index 1cb308cc0d1e10aca5026919e1d721661426512c..8fd5a6260b97240fb09e1f414d1aaa133abf0f6a 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -2163,31 +2163,6 @@ void engine_rebuild(struct engine *e, int repartitioned,
 
   const ticks tic = getticks();
 
-  /* Perform FOF search to seed black holes. */
-  if (e->policy & engine_policy_fof && e->run_fof) {
-
-    /* Initialise FOF parameters and allocate FOF arrays. */
-    fof_init(e->s);
-
-    /* Make FOF tasks and activate them. */
-    engine_make_fof_tasks(e);
-
-    /* Perform local FOF tasks. */
-    engine_launch(e);
-
-    /* Perform FOF search over foreign particles and 
-     * find groups which require black hole seeding.  */
-    fof_search_tree(e->s);
-  
-    /* Reset flag. */
-    e->run_fof = 0;
-
-    if(engine_rank == 0)
-      message("Complete FOF search took: %.3f %s.",
-          clocks_from_ticks(getticks() - tic), clocks_getunit());
-   
-  }
-
   /* Clear the forcerebuild flag, whatever it was. */
   e->forcerebuild = 0;
   e->restarting = 0;
@@ -2341,6 +2316,10 @@ void engine_prepare(struct engine *e) {
     message("Communicating rebuild flag took %.3f %s.",
             clocks_from_ticks(getticks() - tic3), clocks_getunit());
 
+  /* Perform FOF search to seed black holes. Only if there is a rebuild coming and no repartitioing. */
+  if (e->policy & engine_policy_fof && e->forcerebuild && 
+      !e->forcerepart && e->run_fof) engine_fof(e);
+
   /* Do we need repartitioning ? */
   if (e->forcerepart) {
 
@@ -5785,3 +5764,34 @@ void engine_struct_restore(struct engine *e, FILE *stream) {
   e->forcerebuild = 1;
   e->forcerepart = 0;
 }
+
+/**
+ * @brief Run a FOF search.
+ *
+ * @param e the engine
+ */
+void engine_fof(struct engine *e) {
+
+  ticks tic = getticks();
+
+  /* Initialise FOF parameters and allocate FOF arrays. */
+  fof_init(e->s);
+
+  /* Make FOF tasks and activate them. */
+  engine_make_fof_tasks(e);
+
+  /* Perform local FOF tasks. */
+  engine_launch(e);
+
+  /* Perform FOF search over foreign particles and 
+   * find groups which require black hole seeding.  */
+  fof_search_tree(e->s);
+
+  /* Reset flag. */
+  e->run_fof = 0;
+
+  if(e->verbose && engine_rank == 0)
+    message("Complete FOF search took: %.3f %s.",
+        clocks_from_ticks(getticks() - tic), clocks_getunit());
+
+}
diff --git a/src/engine.h b/src/engine.h
index 206a6e7945006c339b3ef5ad1c68619d6b013a57..686856f452c0d5b284afadb88c64da0d88f33791 100644
--- a/src/engine.h
+++ b/src/engine.h
@@ -481,6 +481,7 @@ void engine_unpin(void);
 void engine_clean(struct engine *e);
 int engine_estimate_nr_tasks(const struct engine *e);
 void engine_print_task_counts(const struct engine *e);
+void engine_fof(struct engine *e);
 
 /* Function prototypes, engine_maketasks.c. */
 void engine_maketasks(struct engine *e);