Add ZKLock::open, fix a nasty bug and source refactoring