diff --git a/examples/test_qr_mpi.c b/examples/test_qr_mpi.c
index 3dcddffae90479f500c32fc37cd1f12027d8589c..1eaec06b05f7b01a34b024c0aa30d61d190c2345 100644
--- a/examples/test_qr_mpi.c
+++ b/examples/test_qr_mpi.c
@@ -597,8 +597,8 @@ if(MpiThreadLevel != MPI_THREAD_MULTIPLE)
                 printf("Ran DSSRFT with k = %lli, j = %lli, i = %lli\n", kk, jj, ii);
         }*/
         toc_run = getticks();
-        message("tid = %lli", tid);
-        message("sizeof arrays = %i", m*n*m*n);
+//        message("tid = %lli", tid);
+//        message("sizeof arrays = %i", m*n*m*n);
         task_start[tid] = tic - start;
         task_finish[tid] = toc_run - start;
         task_tids[tid] = omp_get_thread_num();
@@ -699,10 +699,6 @@ if(s.rank == 0) {
     #endif
     qsched_addlock(&s, tid_new, rid[k * m + k]);
     qsched_addlock(&s, tid_new, tau_id[k*m+k]);
-    if(k == 10){
-        message("Task ID of task (10, 10, 10) = %lli", tid_new);
-        message("Resource ID of cell (10,10) = %lli", rid[k*m+k]);
-    }
     if(k == 0)
     {
         memcpy(rids[k*m+k], &A_orig[(data[1]*m+data[0])*K*K], sizeof(double)*K*K);
@@ -727,14 +723,15 @@ if(s.rank == 0) {
       tid_new = qsched_addtask(&s, task_DLARFT, task_flag_none, MPI_data,
                                sizeof(long long int) * 3, 300);
       #endif
-        if(j == 11 && k == 10){
-            message("Task ID of task (10, 11, 10) = %lli", tid_new);
-            message("Adding a use to rid = %lli", rid[k*m+k]);
-        }
         if(k == 0)
         {
            memcpy(rids[j*m+k], &A_orig[(data[1]*m+data[0])*K*K], sizeof(double)*K*K);
         }
+        if(k == 0 && j == 2)
+        {
+            message("Resource ID we use is %lli\n", rid[k*m+k]);
+            message("Task ID is %lli", tid_new);
+        }
       qsched_addlock(&s, tid_new, rid[j * m + k]);
       qsched_adduse(&s, tid_new, rid[k * m + k]);
       qsched_adduse(&s, tid_new, tau_id[k*m+k]);
@@ -831,7 +828,7 @@ FILE *file = NULL;
     else if (s.rank == 3)
         file = fopen("Task_timers3.out", "w");
 
-    for(i = 0; i < m*n*K*K; i++)
+    for(i = 0; i < m*n*m*n; i++)
     {
         if(task_types[i] > 0)
             fprintf(file, "%i %i %lli %lli %i %i %i\n", task_types[i], s.rank*nr_threads+task_tids[i],task_start[i], task_finish[i] ,task_i[i], task_j[i], task_k[i] );
diff --git a/src/qsched.c b/src/qsched.c
index a7cffa08b72da34092a192b1f200a959bcbda241..fee75e321351720270b5319fda3bcd5b81e33b73 100644
--- a/src/qsched.c
+++ b/src/qsched.c
@@ -2196,8 +2196,9 @@ void qsched_integrate( struct qsched *s, struct tsched *ts)
         if(t->type == task_type_send)
         {
             int* data = (int*)(&s->data[t->data]);
-            if(data[0] != s->rank)
+            if(data[0] != s->rank){
                 t->flags |= task_flag_skip;
+            }
         }
         if(t->type == task_type_recv)
         {
@@ -2207,6 +2208,7 @@ void qsched_integrate( struct qsched *s, struct tsched *ts)
         }
     }
 
+
     /* Once this is done, we need to sort out the arrays and fix the pointers to the locks/unlocks arrays.*/
      #pragma omp parallel
         {
@@ -2419,7 +2421,7 @@ for(i = 0; i < count; i++)
         num_current = 0;
         int num_skipped = 0;
         int last_index = -1;
-        for(k = num_parents; k >= 0; k--)
+        for(k = num_parents-1; k >= 0; k--)
         {
             struct task *t2 = &s->tasks[ gettaskindex(tid[parents[k]], s)];
             int found = 0;
@@ -2620,7 +2622,7 @@ for(i = 0; i < count; i++)
         num_current = 0;
         int num_skipped = 0;
         int last_index = -1;
-        for(k = num_parents; k >= 0; k--)
+        for(k = num_parents-1; k >= 0; k--)
         {
             struct task *t2 = &s->tasks[ gettaskindex(tid[parents[k]], s)];
             for(l = 0; l < t2->nr_locks; l++)
@@ -2671,6 +2673,16 @@ for(i = 0; i < count; i++)
             continue;
         }/* If no current parents.*/
 
+        if(t->uses[0] == 0 && t->id == 2 )
+        {
+            message("num_parent = %i", num_parents);
+            message("We found it with num_current = %i", num_current);
+            message("wait_init is %i", wait_init[gettaskindex(t->id,s)]);
+            for(l = 0; l < num_current; l++)
+            {
+                message("parent %i = %lli", l, tid[current_parents[l]]);
+            }
+        }
         /* Check how many parents we skipped. */
         if(num_skipped > 0)
         {
@@ -3202,7 +3214,7 @@ for(i = 0; i < node_count; i++)
     for ( i = 0 ; i < s->task_ranks[s->count_ranks] ; i++ ) {
     	t = &s->tasks[gettaskindex(tid[i], s)];
     	int node = t->node;
-    	if(node != s->rank){
+    	if(node != s->rank && t->type > 0){
     		t->flags |= task_flag_skip;
            }
        for(j = 0; j < t->nr_locks; j++ ) {
@@ -3227,7 +3239,6 @@ for(i = 0; i < node_count; i++)
     free(edgelist_vwgt);
     free(nodelist);
 
-
         
 #else
     error("Quicksched wasn't compiled with MPI support");
@@ -3401,12 +3412,15 @@ if(tid == NULL)
         queue_init( &s->queues[k] , count );
 
     /* Run through the tasks and enqueue the non-waiting ones. */
-    for ( k = 0 ; k < count ; k++ ) {
+    for ( k = 0 ; k < s->task_ranks[s->count_ranks] ; k++ ) {
         t = &tasks[gettaskindex(tid[k],s)];
+
         if ( t->wait == 0 && !( t->flags & task_flag_skip ) )
+        {
             qsched_enqueue( s , t );
         }
-        
+        }
+
     /* Clean up. */
     free( tid );
         
@@ -3797,6 +3811,8 @@ void qsched_enqueue ( struct qsched *s , struct task *t ) {
         resID += (long long int) data[3];
         int tag = data[4];
         struct res *resource = &s->res[getindex(resID, s)];
+        if(resource->ID == 0)
+            message("Emitting resource 0 ISEND");
         int err;
 //        printf("Sending tag = %i\n", tag);
         if(resource->data == NULL)
@@ -3836,6 +3852,8 @@ void qsched_enqueue ( struct qsched *s , struct task *t ) {
         int tag = data[4];
         long long int parent_id = -1;
         struct res *resource = &s->res[getindex(resID, s)];
+        if(resource->ID == 0)
+            message("Emitting resource 0 IRECV with tag %i", tag);
         if(resource->parent >=0)
         {
             /* Recurse and check if any of the parents exist locally.*/
@@ -4091,7 +4109,6 @@ int qsched_locktask ( struct qsched *s , long long int tid ) {
     /* Get a pointer on the task. */
     t = &s->tasks[gettaskindex(tid,s)];
 
-    
 /* Communication task? */
   if (t->type == task_type_recv || t->type == task_type_send) {