Fix object deregistration during detachment