Cse rewrite

A rewrite of common-subexpression-elimination. The old version was pretty flaky.
Right, of course, many of my comments along this line are invalid. Sorry about that.