This also fixes a bug if no hosts were returned where the job would run over and over in a loop, and some other cleanup.