f Move empty-key checks before taking locks