Fix bug in undo/redo