Fix the multithreading stuff