Undo accounts for invalid paste and clear, bug...

after deleting row(s), undo doesn't have correct id for updating
database.