Fixed undo/redo bug when opening new files.