Improved version of the scheduler.
Merge pull request #13 from mickdelange/scheduler2

Improved version of the scheduler.