Slight refactor of the scoping problem fix and fix and fixed the batch template processing.