Added most of the undo functionality. Tell me if it is terrible or terribly wrong.