Simplify/fix locking