Cse rewrite

A rewrite of common-subexpression-elimination. The old version was pretty flaky.
commented-out code and unreachable assert are presumably scalpel-left-in-patient? should be cleaned before submit.