Starting
Adding block detection
Refactoring lock detection code