Changes to orphan deletion code