Handle locks properly