Change the way locks are used to avoid hangs waiting for locks