Simplify usage of 'aggregate' and 'count' in scripts.