Added stale job resolution logic and unittest. Refactored dependency
check ordering.