Scheduler fixes and more unit tests.