Fixed deadlock problem