Refactor aggregation module.