Added pid as an override to statistics cleanups so testing can be made on staging data.
- Also fixed a min_date vs date_min variable naming bug and improved stat sort logic by including the autoinc value