This merge request does some housekeeping within batch.py to reduce the amount of repeated code.
batch.py