diff --git a/src/qsched.c b/src/qsched.c
index 02ae50fd6c117a697992d8340863730b6db9bfdc..8bb6bd8e204908bf66cbf2908102b6ad17676590 100644
--- a/src/qsched.c
+++ b/src/qsched.c
@@ -1859,10 +1859,12 @@ for(i = 0; i < count; i++)
         for(k = num_parents; k >= 0; k--)
         {
             struct task *t2 = &s->tasks[ gettaskindex(tid[parents[k]], s)];
+            int found = 0;
             for(l = 0; l < t2->nr_locks; l++)
             {
                 if(t2->locks[l] == t->locks[j])
                 {
+                    found = 1;
                     current_parents[num_current++] = k;
                     if(k > last_index)
                         last_index = k;
@@ -1871,7 +1873,42 @@ for(i = 0; i < count; i++)
                         num_skipped++;
                     break;
                 }
-            }
+                struct res *r = &s->res[getindex(t2->locks[l],s)];
+                while(r->parent != -1)
+                {
+                    r = &s->res[getindex(r->parent,s)];
+                    if(r->ID == t->locks[j])
+                    {
+                        found = 1;
+                        current_parents[num_current++] = 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->locks[l],s)];
+                while(r->parent != -1)
+                {
+                    r = &s->res[getindex(r->parent,s)];
+                    if(r->ID == t2->locks[l])
+                    {
+                        found = 1;
+                        current_parents[num_current++] = 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;
+                    }
+                }
+            } /* l over locks*/
         }/* k over parents. */
 
         /* We have the current parents. */
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c6b5a7d26fb72257ce5da38ee5054f426f375dbc..38dcb0fcdb163ed699faa8f8197788ce40762295 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -39,4 +39,4 @@ test_mpi_CFLAGS = $(AM_CFLAGS) -DWITH_MPI
 #test_mpi_synchronize_LDFLAGS = $(MPI_THREAD_LIBS)
 #test_mpi_synchronize_SOURCES = test_mpi_synchronize.c
 #test_mpi_synchronize_CFLAGS = $(AM_CFLAGS) -DWITH_MPI
-test_mpi_synchronize_LDADD =  ../src/.libs/libquickschedMPI.a
+#test_mpi_synchronize_LDADD =  ../src/.libs/libquickschedMPI.a