bug fixes to unlocking logic