Merge overlapping patterns, move declarations
Merge pull request #439 from Dmitry-Me/moveDeclarationMergePatterns

Merge overlapping patterns, move declarations