Fix some race conditions

I've ran docker-stress for two hours without any race conditions and deadlocks.
this is racy