Complete scheduler framework (fully commented, NOT tested)