undo/redo and save bug fixes