Keeping better track of deleted records, not deleting when duplicating, other bug fixes