Minor refactoring of PatternMatching.