Update for multithreading and cleanup