Refactor code relevant to the scheduler

Just updated the scheduler related code to the latest refactoring.

Signed-off-by: Konrad Reiche <konrad.reiche@gmail.com>