initial changes to allow for threading, not fully threaded yet