Moved scheduler init code into seperate function