diff --git a/debugging/fileutil.cpp b/debugging/fileutil.cpp
index f4dcc731bcc869e38495d5b36afd60b2aba20bb9..93acfddc94379f2853ce51e5ac69282e3989f302 100644
--- a/debugging/fileutil.cpp
+++ b/debugging/fileutil.cpp
@@ -20,21 +20,29 @@ using namespace std;
 int main(int argc, char **argv)
 {
   int cur = 0;
-  char *lines[16536];
-  char line[80];
+  char *lines[35000];
+  char line[700];
   // Fix num lines, num columns, strdup-1
-  FILE *fin = fopen("bible.txt", "r");
+  FILE *fin = fopen("bible.txt", "r");
+  if (fin==NULL){
+    printf("File cannot be open \n" );
+    return 0;
+  }
+  printf("Hej\n" );
   while (!feof(fin)) {
     getline(line, fin);
     lines[cur] = (char*) malloc(strlen(line));
     strcpy(lines[cur], line);
+    printf("%d\n",cur );
     cur++;
   }
   fclose(fin);
   FILE *fout = fopen("copy.txt", "w");
   for (int i=0; i<cur; i++) {
     fputs(lines[i], fout);
+    free(lines[i]);
   }
+
   fclose(fout);
   return 0;
 }
diff --git a/debugging/workitems.c b/debugging/workitems.c
index 0728aead0cd005a2e4cb6fe084d6e437a441fa79..d6237fce4b78c788b5d006695a8c8850b23a4dce 100644
--- a/debugging/workitems.c
+++ b/debugging/workitems.c
@@ -4,6 +4,8 @@
 #include <string.h>
 #include <stdlib.h>
 
+pthread_mutex_t lock;
+
 typedef struct workitem {
   void (*fn)(double *);
   int current;
@@ -14,15 +16,23 @@ typedef struct workitem {
 
 static void* launchThread(void *in)
 {
+
   int n;
   workitem *data = (workitem*) in;
   volatile int started = 0;
   while (!(started = data->started));
   while (1) {
+    pthread_mutex_lock(&lock);
     n = data->current++;
-    if (n >= data->len) break;
+    //printf("%d\n",data->current);
+    if (n >= data->len){
+      pthread_mutex_unlock(&lock);
+      break;
+    }
     data->fn(&data->data[n]);
+    pthread_mutex_unlock(&lock);
   }
+  //rintf("Jag är ute\n" );
   return NULL;
 }
 
@@ -42,7 +52,10 @@ void launchParallel(int numThreads, double *values, int len, void (*fn)(double *
   for (int i=0; i<numThreads; i++) {
     assert(0 == pthread_create(&th[i], NULL, launchThread, data));
   }
+
+  pthread_mutex_lock(&lock);
   data->started = 1;
+  pthread_mutex_unlock(&lock);
   for (int i=0; i<numThreads; i++) {
     assert(th[i] && 0==pthread_join(th[i], NULL));
   }
@@ -57,11 +70,17 @@ void mul2(double *d)
 
 int main(int argc, char **argv)
 {
+  if (pthread_mutex_init(&lock, NULL) != 0) {
+        printf("\n mutex init has failed\n");
+        return 1;
+  }
+
   double vals[100];
   for (int i=0; i<100; i++) {
     vals[i] = i*1.5;
   }
-  launchParallel(4 /* Increase this if no error occurs */, vals, 100, mul2);
+  launchParallel(8 /* Increase this if no error occurs */, vals, 100, mul2);
+
   for (int i=0; i<100; i++) {
     if (vals[i] != 1.5*2*i) {
       fprintf(stderr, "Expected vals[%d] to have value %.1f, got value %.1f\n", i, (double)1.5*2*i, (double)vals[i]);
diff --git a/julia/run.jl b/julia/run.jl
index 0f4341ac966bfad3fedeaaa1aeeea08ccec43992..20a34525653431262b34c45f32284c35d7f33eee 100644
--- a/julia/run.jl
+++ b/julia/run.jl
@@ -43,6 +43,6 @@ function testDoWhile()
     @assert a < 18
     a += 1
     println(a)
-  end a==100
+    end a==100
 end
 testDoWhile()