Fixed invalid lock release. Adding some comments. fixes #16