Replaced 'chmatch2' with a ~14x faster version. Perhaps this function could be useful and should be exported?