Fix bug with undo/redo