Instead of map/reduce, using aggregate to avoid creating temporary objects.