Fix the deadlock issues