(More) correct mutex locking