Fixed multithreaded operation. Thanks Sarbian!