Fix deadlock in refactored code.