Refactored handle_job_recovery. The variable iter was
used twice. The names were changed and their definitions
moved to where they were used for clarity.