fix bug in TotalCounts; add 'aggregate' argument