MERGE refactoring

Refactoring of how MERGE is parsed, in preparation for MERGE for patterns