Merge pull request #6 from glutamatt/master

Use single transaction to acquire lock