fix usage of scoped locks

previously they were getting destroyed
immediately because they were not stored in a
temporary scope variable
Merge pull request #65 from wjwwood/fix_locking

fix usage of scoped locks