Aggregator optimization

Merge functionality into master.