Fixes to the multiclass filtering and sorting