More robust aggregation

Replaces #565. Review by @cvogt