diff --git a/src/cell.c b/src/cell.c
index 9911b8fb862df88b7f00b1ab1eed51af92346bb8..0ed97224e91c3a360c0bb0dd99e3534594457300 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -176,7 +176,7 @@ int cell_pack ( struct cell *c , struct pcell *pc ) {
     pc->dt_min = c->dt_min;
     pc->dt_max = c->dt_max;
     pc->count = c->count;
-    c->tag = pc->tag = rand() % (1 << 24);
+    c->tag = pc->tag = ( ((long long int)c) / sizeof(struct cell) ) % (1 << 30);
     
     /* Fill in the progeny, depth-first recursion. */
     for ( k = 0 ; k < 8 ; k++ )
diff --git a/src/engine.c b/src/engine.c
index 1333e2a6140b4fe737d6d95783a16c2f0eb04d4f..08905a32fdf6e00dec8f7c0b5f3dc608b22b232a 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -743,7 +743,7 @@ int engine_exchange_strays ( struct engine *e , struct part *parts , struct xpar
     
     /* Wait for each part array to come in and collect the new
        parts from the proxies. */
-    for ( k = 0 ; k < nr_in ; k++ ) {
+    for ( k = 0 ; k < 2*(nr_in + nr_out) ; k++ ) {
         if ( MPI_Waitany( 2*e->nr_proxies , reqs_in , &pid , &status ) != MPI_SUCCESS ||
              pid == MPI_UNDEFINED )
             error( "MPI_Waitany failed." );