Added FunctionDef support
Added first versions of functions to storage.
Inlined runReport to prepare for refactoring.
Refactored runReport to use the database for the majority of the aggregation logic.
Removed the unnecessary inclusion of the actual record type in runReport.