Fix for Bug #1098, and some reworking of the lock code

This code currently has all calls to getLockLevel in places where it will only return 0 or higher.