Fix bug in task schedling.