Fixed grouping/sorting bug