Fix for deadlocks
Merge pull request #647 from bhariharan/master

Fix for deadlocks