Refactored scheduling, exploiting the new dependency graph and the info we store there.