Corrected scope management: remove ids/scope elements when resource is
deleted.