Refactored TaskManager to include time-based scheduling.