Quick deadlock fixes. May be unstable.