Implement MAX_BY and further improvements to aggregations

Talked to @dain this can't rely on getSlice(), it should have a switch on the stack type instead