optimization for matches and class assignments, fix for a bug in this case