diff --git a/examples/test_qr_mpi.c b/examples/test_qr_mpi.c
index 1eaec06b05f7b01a34b024c0aa30d61d190c2345..b24bc09b145f2ee08e78c48e205ade34002d52b6 100644
--- a/examples/test_qr_mpi.c
+++ b/examples/test_qr_mpi.c
@@ -597,6 +597,10 @@ if(MpiThreadLevel != MPI_THREAD_MULTIPLE)
                 printf("Ran DSSRFT with k = %lli, j = %lli, i = %lli\n", kk, jj, ii);
         }*/
         toc_run = getticks();
+        if(type == task_DGEQRF){
+            if(idata[2] == 2)
+                message("Ran task (2,2,2)");
+        }
 //        message("tid = %lli", tid);
 //        message("sizeof arrays = %i", m*n*m*n);
         task_start[tid] = tic - start;
@@ -699,6 +703,11 @@ 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 ==2 )
+    {
+        message("Task (2,2,2) == %lli", tid_new);
+        message("Resource (2,2) == %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);
@@ -723,15 +732,12 @@ if(s.rank == 0) {
       tid_new = qsched_addtask(&s, task_DLARFT, task_flag_none, MPI_data,
                                sizeof(long long int) * 3, 300);
       #endif
+        if(k == 2 && j == 6)
+            message("Task (2,6,2) == %lli", tid_new);
         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]);
diff --git a/src/qsched.c b/src/qsched.c
index fee75e321351720270b5319fda3bcd5b81e33b73..c70a3495b5ed3606ca32247240f44b36bac1d045 100644
--- a/src/qsched.c
+++ b/src/qsched.c
@@ -2430,7 +2430,7 @@ for(i = 0; i < count; i++)
                 if(t2->locks[l] == t->locks[j])
                 {
                     found = 1;
-                    current_parents[num_current++] = k;
+                    current_parents[num_current++] = parents[k];
                     if(k > last_index)
                         last_index = k;
                     /* If we skipped the parent task, increment the number we skipped. */
@@ -2445,7 +2445,7 @@ for(i = 0; i < count; i++)
                     if(r->ID == t->locks[j])
                     {
                         found = 1;
-                        current_parents[num_current++] = k;
+                        current_parents[num_current++] = parents[k];
                         if(k > last_index)
                             last_index = k;
                         /* If we skipped the parent task, increment the number we skipped. */
@@ -2464,7 +2464,7 @@ for(i = 0; i < count; i++)
                     if(r->ID == t2->locks[l])
                     {
                         found = 1;
-                        current_parents[num_current++] = k;
+                        current_parents[num_current++] = parents[k];
                         if(k > last_index)
                             last_index = k;
                         /* If we skipped the parent task, increment the number we skipped. */
@@ -2627,9 +2627,10 @@ for(i = 0; i < count; i++)
             struct task *t2 = &s->tasks[ gettaskindex(tid[parents[k]], s)];
             for(l = 0; l < t2->nr_locks; l++)
             {
+                int found = 0;
                 if(t2->locks[l] == t->uses[j])
                 {
-                    current_parents[num_current++] = k;
+                    current_parents[num_current++] = parents[k];
                     if(k > last_index)
                         last_index = k;
                     /* If we skipped the parent task, increment the number we skipped. */
@@ -2637,6 +2638,41 @@ for(i = 0; i < count; i++)
                         num_skipped++;
                     break;
                 }
+                struct res *r = &s->res[getindex(t->uses[l],s)];
+                while(r->parent != -1)
+                {
+                    r = &s->res[getindex(r->parent,s)];
+                    if(r->ID == t->uses[j])
+                    {
+                        found = 1;
+                        current_parents[num_current++] = parents[k];
+                        if(k > last_index)
+                            last_index = k;
+                        /* If we skipped the parent task, increment the number we skipped. */
+                        if(t2->flags & task_flag_skip)
+                            num_skipped++;
+                        break;
+                    }
+                }
+                if(found)
+                    continue;
+
+                r = &s->res[getindex(t->uses[l],s)];
+                while(r->parent != -1)
+                {
+                    r = &s->res[getindex(r->parent,s)];
+                    if(r->ID == t2->uses[l])
+                    {
+                        found = 1;
+                        current_parents[num_current++] = parents[k];
+                        if(k > last_index)
+                            last_index = k;
+                        /* If we skipped the parent task, increment the number we skipped. */
+                        if(t2->flags & task_flag_skip)
+                            num_skipped++;
+                        break;
+                    }
+                }
             }
         }/* k over parents. */
 /*        if( t->uses[j] == 340)
@@ -2673,16 +2709,7 @@ 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)
         {
@@ -2709,6 +2736,7 @@ for(i = 0; i < count; i++)
 
                 /* Create the recv task*/
                 recv_task_id = tsched_addtask(&ts, task_type_recv , 0 , task_data , 5 * sizeof(int) , s->res[getindex(t->uses[j],s)].size );
+
                 /* The recv task unlocks this task locally. */
                 tsched_addunlock( &ts, recv_task_id, t->id);
                 /* The recv task needs to lock the resource. */
@@ -3811,8 +3839,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");
+        if(t->id == 281474976710656)
+            message("Emitting Isend for (2,2) after (2,2,2)");
         int err;
 //        printf("Sending tag = %i\n", tag);
         if(resource->data == NULL)
@@ -3852,8 +3880,6 @@ 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.*/