Fix some exponential behavior in the simplifier.

And add a test that it broke.