Rewrite to do 2 pass generation with tracable aggregation