Added simple multithreading support