public function fixMetadataReferences(Resource $meta): Resource {
        $properties = array_diff($meta->propertyUris(), array(RC::idProp()));
        foreach ($properties as $p) {
            foreach ($meta->allResources($p) as $obj) {
                $id  = null;
                $uri = $obj->getUri();
                try {
                    $res = $this->getResourceById($uri);
                    $id  = $res->getId();
                } catch (NotFound $e) {
                    try {
                        $res = $this->getResourceByUri($uri);
                        $id  = $res->getId();
                    } catch (NotFound $e) {
                        
                    } catch (NoAcdhId $e) {
                        
                    } catch (ClientException $e) {
                        
                    }
                } catch (NoAcdhId $e) {
                    
                } catch (ClientException $e) {
                    
                }

                if ($id !== null && $id !== $obj->getUri()) {
                    $meta->delete($p, $obj);
                    $meta->addResource($p, $id);
                }
            }
        }
        return $meta;
    }