Fix locking and command status output