added cleanup of aggregates if max count in memory is exceeded