Implement MAX_BY and further improvements to aggregations