Improved memory handling on aggregation