Refactored out the logic for determining the state of a job from the states of its tasks.