Fixed some multithreading bugs
Fixed