Fix locking and switch turning off