bugid: 52072 -- refactor tag matching to work effectively at regular complexity