Added undo / redo

Also fixed a small bug in __toString