Improve performance of aggregate

This version is now approximately 10 times faster when calling aggregate
with a list of 2 million numbers generated from (random).