Still having problems with the mutex, but made a little progress