Fixing Undo and Redo Bugs