Added grouping to profile matrix generator.