More pattern matching fixes
Merge