Better aggregation support

Added support and tests for aggregation operations.
Probably on the whole thing+tests. My IntelliJ settings are geared towards what our shop decided, if you can point me to the settings you use I'll reformat the lot :smile: