Moved undo code to the new UndoManager utility class.