Small bugfix and refactoring
Refactored scheduling into separate class
Refactored rest handling