cleanup, replace a couple of aggregation pipelines with good ol python loops