Significant performance improvements, especially to undo.

Now runs as fast as it used to. Nitro sucks.