cleaned up 'aggregate', added documentation