Multithreading fixes.