Changed unlock and lock functions to use mutex.