Script seems to work, multithreading is done properly now