routinely check pthread library calls
fixed bug where I forgot to initialise mutex objects