Fixed regression in ingest stats query
Fixed synax error
Fix merge conflict
Removed globals, removed cache, improved design