Better aggregation support

Added support and tests for aggregation operations.