diff --git a/src/cell.c b/src/cell.c
index 2d4ae2551ebceea1c85d65a2dcbcebce52a4fd52..de1f6f87e9f524616ccd609c25de3e652e423874 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -70,6 +70,8 @@
 #include "tools.h"
 #include "tracers.h"
 
+extern int engine_star_resort_task_depth;
+
 /* Global variables. */
 int cell_next_tag = 0;
 
@@ -2397,6 +2399,19 @@ void cell_clear_limiter_flags(struct cell *c, void *data) {
                   cell_flag_do_hydro_limiter | cell_flag_do_hydro_sub_limiter);
 }
 
+void cell_activate_star_resort_tasks(struct cell *c, struct scheduler *s) {
+
+  if (c->depth == engine_star_resort_task_depth || c->hydro.super == c) {
+    scheduler_activate(s, c->hydro.stars_resort);
+  } else {
+    for (int k = 0; k < 8; ++k) {
+      if (c->progeny[k] != NULL) {
+        cell_activate_star_resort_tasks(c->progeny[k], s);
+      }
+    }
+  }
+}
+
 void cell_activate_star_formation_tasks(struct cell *c, struct scheduler *s) {
 
   if (c->depth != 0) error("Function should be called at the top-level only");
@@ -2407,20 +2422,8 @@ void cell_activate_star_formation_tasks(struct cell *c, struct scheduler *s) {
   /* Activate the star formation task */
   scheduler_activate(s, c->hydro.star_formation);
 
-  /* Shallow tree case -> the resort task is at this level */
-  if (c->hydro.super == c) {
-    scheduler_activate(s, c->hydro.stars_resort);
-  }
-
-  /* Deep tree case -> the resort is in the progenies */
-  else {
-
-    for (int k = 0; k < 8; ++k) {
-      if (c->progeny[k] != NULL) {
-        scheduler_activate(s, c->progeny[k]->hydro.stars_resort);
-      }
-    }
-  }
+  /* Activate the star resort tasks at whatever level they are */
+  cell_activate_star_resort_tasks(c, s);
 }
 
 /**
diff --git a/src/engine.h b/src/engine.h
index 967a430871648ac4cb91f390f8b85675a314d3a8..dc5c2c9ddd9a843d3e677e9b56c47f7451515b2f 100644
--- a/src/engine.h
+++ b/src/engine.h
@@ -113,6 +113,7 @@ enum engine_step_properties {
 #define engine_default_timesteps_file_name "timesteps"
 #define engine_max_parts_per_ghost_default 1000
 #define engine_max_sparts_per_ghost_default 1000
+#define engine_star_resort_task_depth_default 2
 #define engine_tasks_per_cell_margin 1.2
 
 /**
diff --git a/src/engine_maketasks.c b/src/engine_maketasks.c
index a3d6ad0423dcf29248a23b311b745e17285ace1c..3759ac26f969655edfac9452e044ec954476191c 100644
--- a/src/engine_maketasks.c
+++ b/src/engine_maketasks.c
@@ -54,6 +54,7 @@
 
 extern int engine_max_parts_per_ghost;
 extern int engine_max_sparts_per_ghost;
+extern int engine_star_resort_task_depth;
 
 /**
  * @brief Add send tasks for the gravity pairs to a hierarchy of cells.
@@ -987,29 +988,17 @@ void engine_make_hierarchical_tasks_hydro(struct engine *e, struct cell *c,
   const int with_star_formation = (e->policy & engine_policy_star_formation);
   const int with_black_holes = (e->policy & engine_policy_black_holes);
 
-  /* Are we at the top-level but this is also the super-level? */
-  if (c->top == c && c->nodeID == e->nodeID) {
-
-    /* Record this is the level where we re-sort */
-    star_resort_cell = c;
+  /* Are we are the level where we create the stars' resort tasks?
+   * If the tree is shallow, we need to do this at the super-level if the
+   * super-level is above the level we want */
+  if ((c->nodeID == e->nodeID) && (star_resort_cell == NULL) &&
+      (c->depth == engine_star_resort_task_depth || c->hydro.super == c)) {
 
     if (with_star_formation && c->hydro.count > 0) {
 
-      if (c->hydro.super == c) {
+      /* Record this is the level where we re-sort */
+      star_resort_cell = c;
 
-        c->hydro.stars_resort = scheduler_addtask(
-            s, task_type_stars_resort, task_subtype_none, 0, 0, c, NULL);
-        scheduler_addunlock(s, c->hydro.star_formation, c->hydro.stars_resort);
-      }
-    }
-  }
-
-  if (c->depth == 1 && c->nodeID == e->nodeID) {
-
-    /* Record this is the level where we re-sort */
-    star_resort_cell = c;
-
-    if (with_star_formation && c->hydro.count > 0) {
       c->hydro.stars_resort = scheduler_addtask(
           s, task_type_stars_resort, task_subtype_none, 0, 0, c, NULL);
 
diff --git a/src/space.c b/src/space.c
index 250af5efafa506408c9fd91c1adffb7cd96a1a21..40dc87fdc5b3e2bde5bb0ffaf1c723516041d3b0 100644
--- a/src/space.c
+++ b/src/space.c
@@ -91,6 +91,7 @@ int space_extra_gparts = space_extra_gparts_default;
 /*! Maximum number of particles per ghost */
 int engine_max_parts_per_ghost = engine_max_parts_per_ghost_default;
 int engine_max_sparts_per_ghost = engine_max_sparts_per_ghost_default;
+int engine_star_resort_task_depth = engine_star_resort_task_depth_default;
 
 /*! Expected maximal number of strays received at a rebuild */
 int space_expected_max_nr_strays = space_expected_max_nr_strays_default;