added a scheduler and various methods to support it