Revert deadlock

My recent PR somehow added a deadlock scenario when dealing with the mutex. This PR reverts my last two commits.

Sorry :(