Coalescing fixes

This PR fixes a few bugs related to the coalescer, where certain operations would receive incorrect results or be grouped incorrectly.