tidy and fix a small typecast error
comments
Impose limit on grouping sets _before_ expansions that might
consume significant memory.