Improved unsetting references for deleted records