Split generation of uncaptured rows and occasion rows to separate files.  They are not self-contained, getting close to a clean env. between scripts.
Moving more of the ATS-specific code here in generic form.