GRP-1041: Add index for type_of_group and simplify some queries that depend on type_of_group.