Fix locking issues