Initial cut of a spreading scheduler.
Add a generic scheduler.
Refactor the code to make it more readable.
Merge pull request #1420 from brendandburns/scheduler

Initial cut of a spreading and generic scheduler.