Fixed (almost) all bugs in UndoRedoController.