Better lock handling