fix locking problems