Added multithreading support.