Removed unecessary code
Rewriting the multithreaded functionality.