Cse rewrite

A rewrite of common-subexpression-elimination. The old version was pretty flaky.
compare_names already set result