#658 Merge 3.11/658_orphan_entries into 3.11/sprint
Revert most changes since instances were already cleand by the following statement:
_transaction.addDeleteStmt(rows->getKey());
Verified manually that it works as expected with both MySQL and sqlite DBs.