Refactored Lock class