Improved PatternMatcher