diff --git a/src/engine.c b/src/engine.c
index 9677b151b9bae35418cf0c2b430999ae0ddf1402..999bd59af74e7b726543ba39c226b8f29fccd61d 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -783,6 +783,7 @@ void engine_init ( struct engine *e , struct space *s , float dt , int nr_thread
     
     /* Init the scheduler. */
     scheduler_init( &e->sched , e->s , nr_queues , scheduler_flag_steal );
+    s->nr_queues = nr_queues;
         
     /* Append a kick1 task to each cell. */
     scheduler_reset( &e->sched , s->tot_cells );
diff --git a/src/space.c b/src/space.c
index 41d6d04f08ecedeb7cfb368a9e484afe5f3fdf2e..a1fb6074f91bc238983281a72395af83ccafacc0 100644
--- a/src/space.c
+++ b/src/space.c
@@ -686,10 +686,12 @@ void space_split ( struct space *s , struct cell *c ) {
                 if ( c->progeny[k]->maxdepth > maxdepth )
                     maxdepth = c->progeny[k]->maxdepth;
                 }
-            c->h_max = h_max;
-            c->dt_min = dt_min;
-            c->dt_max = dt_max;
-            c->maxdepth = maxdepth;
+                
+        /* Set the values for this cell. */
+        c->h_max = h_max;
+        c->dt_min = dt_min;
+        c->dt_max = dt_max;
+        c->maxdepth = maxdepth;
                 
         }
         
@@ -723,6 +725,9 @@ void space_split ( struct space *s , struct cell *c ) {
         c->dt_max = dt_max;
             
         }
+        
+    /* Set ownership accorind to the start of the parts array. */
+    c->owner = ( c->parts - s->parts ) * s->nr_queues / s->nr_parts;
 
     }
 
@@ -838,6 +843,7 @@ void space_init ( struct space *s , double dim[3] , struct part *parts , int N ,
     s->nr_parts = N;
     s->parts = parts;
     s->cell_min = h_max;
+    s->nr_queues = 1;
     
     /* Allocate and link the xtra parts array. */
     if ( posix_memalign( (void *)&s->xparts , 32 , N * sizeof(struct xpart) ) != 0 )
diff --git a/src/space.h b/src/space.h
index 40788bd24f70e768e83724447818da9a185c9643..2f970091c8ce7c217e34562c86066024affadcbf 100644
--- a/src/space.h
+++ b/src/space.h
@@ -93,6 +93,9 @@ struct space {
     /* General-purpose lock for this space. */
     lock_type lock;
     
+    /* Number of queues in the system. */
+    int nr_queues;
+    
     };