Undo system

And a bunch of random stuff.