Rewrite pattern matching to be greedy from left (closes #86)