Erikbern/scheduler refactoring

A series of minor fixes to the scheduler to simplify the code. Need to do these refactorings to do some larger stuff later.