Start deadlock

Same fix as https://bitbucket.org/nsoffer/yappi/branch/start-deadlock, but 2 patches instead of 3 (it is easier for me to work with git).