updated length test in writeLockState and fixed last of the compile issues