Moved mode related code from Job to Mode.