performance tweaks for matchPalette