#463 proposal for deadlock fix
peter's comments addressed
alasdair's comments addressed
Merge pull request #464 from andreaturli/deadlock

#463 proposal for deadlock fix