Refactor quite a bit of the job control code