Refactoring matchUnits.