Fix lock logic.