Implemented multithreading. Appears to be working.