Fix lock management