Add multithreading support