Merge pull request #1 from beatjunky99/master

Pull from upstream
Simplify/fix locking
Merge pull request #2 from joedj/master

Simplify/fix locking