Added multithreading and configs for up to 10^6