Fixed a bug in undo/redo