Fix classes sometimes mistakenly being added to a match group