Fix wrong signature for trended reports. Partial support for query filtering. Light refactoring.