Improved version of the scheduler.