Merge pull request #180 from jnoring/master

Some mutex cleanup, fix for a deadlock