diff --git a/src/task.c b/src/task.c
index ff6bb9bee21de6a77d8a81a8f4f79722e483ad30..e3c217ebe06f2aba47f4ceaf51af40b2e4557e24 100644
--- a/src/task.c
+++ b/src/task.c
@@ -276,8 +276,8 @@ float task_overlap(const struct task *restrict ta,
  */
 void task_unlock(struct task *t) {
 
-  const int type = t->type;
-  const int subtype = t->subtype;
+  const enum task_types type = t->type;
+  const enum task_subtypes subtype = t->subtype;
   struct cell *ci = t->ci, *cj = t->cj;
 
   /* Act based on task type. */
@@ -296,6 +296,7 @@ void task_unlock(struct task *t) {
     case task_type_sub_self:
       if (subtype == task_subtype_grav) {
         cell_gunlocktree(ci);
+        cell_munlocktree(ci);
       } else {
         cell_unlocktree(ci);
       }
@@ -306,15 +307,25 @@ void task_unlock(struct task *t) {
       if (subtype == task_subtype_grav) {
         cell_gunlocktree(ci);
         cell_gunlocktree(cj);
+        cell_munlocktree(ci);
+        cell_munlocktree(cj);
       } else {
         cell_unlocktree(ci);
         cell_unlocktree(cj);
       }
       break;
 
-    case task_type_grav_mm:
+    case task_type_grav_down:
       cell_gunlocktree(ci);
+      cell_munlocktree(ci);
+      break;
+
+    case task_type_grav_top_level:
+    case task_type_grav_long_range:
+    case task_type_grav_mm:
+      cell_munlocktree(ci);
       break;
+
     default:
       break;
   }
@@ -327,8 +338,8 @@ void task_unlock(struct task *t) {
  */
 int task_lock(struct task *t) {
 
-  const int type = t->type;
-  const int subtype = t->subtype;
+  const enum task_types type = t->type;
+  const enum task_subtypes subtype = t->subtype;
   struct cell *ci = t->ci, *cj = t->cj;
 #ifdef WITH_MPI
   int res = 0, err = 0;
@@ -371,7 +382,14 @@ int task_lock(struct task *t) {
     case task_type_self:
     case task_type_sub_self:
       if (subtype == task_subtype_grav) {
-        if (cell_glocktree(ci) != 0) return 0;
+        /* Lock the gparts and the m-pole */
+        if (ci->ghold || ci->mhold) return 0;
+        if (cell_glocktree(ci) != 0)
+          return 0;
+        else if (cell_mlocktree(ci) != 0) {
+          cell_gunlocktree(ci);
+          return 0;
+        }
       } else {
         if (cell_locktree(ci) != 0) return 0;
       }
@@ -380,13 +398,24 @@ int task_lock(struct task *t) {
     case task_type_pair:
     case task_type_sub_pair:
       if (subtype == task_subtype_grav) {
+        /* Lock the gparts and the m-pole in both cells */
         if (ci->ghold || cj->ghold) return 0;
         if (cell_glocktree(ci) != 0) return 0;
         if (cell_glocktree(cj) != 0) {
           cell_gunlocktree(ci);
           return 0;
+        } else if (cell_mlocktree(ci) != 0) {
+          cell_gunlocktree(ci);
+          cell_gunlocktree(cj);
+          return 0;
+        } else if (cell_mlocktree(cj) != 0) {
+          cell_gunlocktree(ci);
+          cell_gunlocktree(cj);
+          cell_munlocktree(ci);
+          return 0;
         }
       } else {
+        /* Lock the parts in both cells */
         if (ci->hold || cj->hold) return 0;
         if (cell_locktree(ci) != 0) return 0;
         if (cell_locktree(cj) != 0) {
@@ -396,8 +425,23 @@ int task_lock(struct task *t) {
       }
       break;
 
+    case task_type_grav_down:
+      /* Lock the gparts and the m-poles */
+      if (ci->ghold || ci->mhold) return 0;
+      if (cell_glocktree(ci) != 0)
+        return 0;
+      else if (cell_mlocktree(ci) != 0) {
+        cell_gunlocktree(ci);
+        return 0;
+      }
+      break;
+
+    case task_type_grav_top_level:
+    case task_type_grav_long_range:
     case task_type_grav_mm:
-      cell_glocktree(ci);
+      /* Lock the m-poles */
+      if (ci->mhold) return 0;
+      if (cell_mlocktree(ci) != 0) return 0;
       break;
 
     default: