TRQ-3012. TRQ-3018. Fix memory leaks that happen whenever jobs are run.