WIP: Aggregates

I still need to add tests, so this code isn't quite ready to merge, but all the functionality should be there...
Good point! I'll give it some thought and see what I can do...