Multithreading fix