Fixed mutex double-locking bug