more bugfixed related to scheduling code