Redmine#6725: refactor the local class matching functions and add tag support to them