Issue #20437: Fixed 21 potential bugs when deleting objects references.