Added multithreading and logging.
Added multithreading and logging.