Cse rewrite

A rewrite of common-subexpression-elimination. The old version was pretty flaky.
Yikes, not only did I leave the test disabled, but the test fails when reenabled! Fixing...