cleanup of TemplateMatcher