Added a compile switch to turn off threading.