Substantial refactoring of scheduling code.