Refactor scheduler.

Initially just implementing a simple scheduler that replicates the previous behavior.