Fixed bug with locks