Cse rewrite

A rewrite of common-subexpression-elimination. The old version was pretty flaky.
Isn't this missing an early-out if result is already non-Equal? It directly sets 'result' below, which might obliterate a previous non-Equal value of result.