Add multithreading
Big cleanup