Restructured again for multithreaded functionality