halfway through refactor.
Refactor scheduler