Fixing the undo history