Initial work to add support for multithreading