Fix max_sched_id and inconsistent variable naming