Fixed undo/redo bug