diff --git a/src/cell.h b/src/cell.h
index 4c101c66dd46cdc193941c10206725283681969a..265c7ef42efa07e8b7c93f97afc143ff70b58747 100644
--- a/src/cell.h
+++ b/src/cell.h
@@ -100,7 +100,7 @@ struct cell {
     int hold;
     
     /* Spin lock for various uses. */
-    lock_type lock, mlock;
+    lock_type lock;
     
     /* ID of the previous owner, e.g. runner. */
     int owner;
diff --git a/src/queue.c b/src/queue.c
index 82bf86c16943a7da8368c5fdb83f2409c6272059..e1a41a9b7380ea0aea8c24843cc7085380a8bf2d 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -187,7 +187,7 @@ struct task *queue_gettask_old ( struct queue *q , int blocking , int keep ) {
                 continue;
             
             /* Different criteria for different types. */
-            if ( res->type == task_type_self || (res->type == task_type_sub && res->cj == NULL) ) {
+            if ( res->type == task_type_self || res->type == task_type_sort || (res->type == task_type_sub && res->cj == NULL) ) {
                 if ( res->ci->hold || cell_locktree( res->ci ) != 0 )
                     continue;
                 }
@@ -317,7 +317,9 @@ struct task *queue_gettask ( struct queue *q , int rid , int blocking , int keep
                 continue;
                 
             /* Try to lock ci. */
-            if ( res->type == task_type_self || (res->type == task_type_sub && res->cj == NULL) ) {
+            if ( res->type == task_type_self || 
+                 res->type == task_type_sort || 
+                 (res->type == task_type_sub && res->cj == NULL) ) {
                 if ( res->ci != ci_best && res->ci != cj_best && cell_locktree( res->ci ) != 0 )
                     continue;
                 }
@@ -336,7 +338,7 @@ struct task *queue_gettask ( struct queue *q , int rid , int blocking , int keep
             /* If we owned a previous task, unlock it. */
             if ( ind_best >= 0 ) {
                 res = &qtasks[ qtid[ ind_best ] ];
-                if ( res->type == task_type_self || res->type == task_type_pair || res->type == task_type_sub )
+                if ( res->type == task_type_self || res->type == task_type_sort || res->type == task_type_pair || res->type == task_type_sub )
                     if ( res->ci != ci_best && res->ci != cj_best )
                         cell_unlocktree( res->ci );
                 if ( res->type == task_type_pair || (res->type == task_type_sub && res->cj != NULL) )
diff --git a/src/runner.c b/src/runner.c
index 836d027096245686314ae6c5502b91a139daa7c0..c28b63876e54efefb6c2e5c79b4c101dd1b5dbdb 100644
--- a/src/runner.c
+++ b/src/runner.c
@@ -186,8 +186,6 @@ void runner_dosort ( struct runner *r , struct cell *c , int flags , int clock )
         return;
     
     /* start by allocating the entry arrays. */
-    if ( lock_lock( &c->mlock ) != 0 )
-        error( "Failed to lock cell." );
     if ( c->sort == NULL || c->sortsize < c->count ) {
         if ( c->sort != NULL )
             free( c->sort );
@@ -195,8 +193,6 @@ void runner_dosort ( struct runner *r , struct cell *c , int flags , int clock )
         if ( ( c->sort = (struct entry *)malloc( sizeof(struct entry) * (c->sortsize + 1) * 13 ) ) == NULL )
             error( "Failed to allocate sort memory." );
         }
-    if ( lock_unlock( &c->mlock ) != 0 )
-        error( "Failed to unlock cell." );
         
     /* Does this cell have any progeny? */
     if ( c->split ) {
@@ -205,10 +201,7 @@ void runner_dosort ( struct runner *r , struct cell *c , int flags , int clock )
         for ( k = 0 ; k < 8 ; k++ ) {
             if ( c->progeny[k] == NULL )
                 continue;
-            if ( c->progeny[k]->sorts == NULL )
-                missing = flags;
-            else
-                missing = ( c->progeny[k]->sorts->flags ^ flags ) & flags;
+            missing = flags & ~c->progeny[k]->sorted;
             if ( missing )
                 runner_dosort( r , c->progeny[k] , missing , 0 );
             }
@@ -735,6 +728,7 @@ void *runner_main ( void *data ) {
                     break;
                 case task_type_sort:
                     runner_dosort( r , ci , t->flags , 1 );
+                    cell_unlocktree( ci );
                     break;
                 case task_type_sub:
                     if ( t->subtype == task_subtype_density )
diff --git a/src/space.c b/src/space.c
index ead5b08ea20199e87056d2aa0f155467faff482b..b2b139b9f3e9a4e72c1a4c0041e1cddf08271166 100644
--- a/src/space.c
+++ b/src/space.c
@@ -1654,9 +1654,8 @@ struct cell *space_getcell ( struct space *s ) {
     
     /* Init some things in the cell. */
     bzero( c , sizeof(struct cell) );
-    if ( lock_init( &c->lock ) != 0 ||
-         lock_init( &c->mlock ) != 0 )
-        error( "Failed to initialize cell spinlocks." );
+    if ( lock_init( &c->lock ) != 0 )
+        error( "Failed to initialize cell spinlock." );
         
     /* Unlock the space. */
     lock_unlock_blind( &s->lock );