Major refactoring of scheduler interface

Wait handlers can now be specified, which allows schedulers to
do other things while a task is blocked waiting for another task.
More scheduler refactoring
Spawn pool threads in parallel, also minor refactoring