Lock/unlock fixes

fixes #23