some refactoring, basic scheduler working