Fixed some multithreaded evilness