diff --git a/entity_mesh.module b/entity_mesh.module
index 6497455d64c905e4adf8a3be07e5022e1e148104..372d66761694fdda8b616079df223d9716f67498 100644
--- a/entity_mesh.module
+++ b/entity_mesh.module
@@ -90,7 +90,7 @@ function entity_mesh_process_entity(EntityInterface $entity, $operation) {
       return;
     }
     $entity_mesh = \Drupal::service($service);
-    $entity_mesh->deleteItem($entity->getEntityTypeId(), $entity->getEntityTypeId());
+    $entity_mesh->deleteItem($entity->getEntityTypeId(), $entity->id());
   }
 
 }
diff --git a/src/Entity.php b/src/Entity.php
index fd9c065d3c6f3baafe075d05ba09aa54e397b1b0..217c85ea5bab1af1e73cf0131c2b7d7f93cf7739 100644
--- a/src/Entity.php
+++ b/src/Entity.php
@@ -75,6 +75,13 @@ abstract class Entity {
    *   The entity to process.
    */
   public function processEntity(EntityInterface $entity) {
+    // Delete source before process entities.
+    $source = $this->createSourceFromEntity($entity);
+    if (!$source instanceof SourceInterface) {
+      return;
+    }
+    $this->entityMeshRepository->deleteSource($source);
+
     // Check if entity is translatable.
     if ($entity instanceof TranslatableInterface && $entity->isTranslatable()) {
       $this->processTranslatableEntity($entity);
@@ -86,15 +93,15 @@ abstract class Entity {
   /**
    * Process a translatable Entity.
    *
-   * @param \Drupal\Core\Entity\EntityInterface $entity
+   * @param \Drupal\Core\Entity\TranslatableInterface $entity
    *   The entity to process.
    */
-  protected function processTranslatableEntity(EntityInterface $entity) {
-    // @phpstan-ignore-next-line
+  protected function processTranslatableEntity(TranslatableInterface $entity) {
+
     $translations = $entity->getTranslationLanguages();
     $langcodes = array_keys($translations);
     foreach ($langcodes as $langcode) {
-      // @phpstan-ignore-next-line
+
       $translation = $entity->getTranslation($langcode);
       if ($translation instanceof EntityInterface) {
         $this->processEntityItem($translation);
diff --git a/src/EntityRender.php b/src/EntityRender.php
index 2d08ec42590c4475e64f6fa24c06db060d7e061b..4c307120289454503d8f604c637110028203432d 100644
--- a/src/EntityRender.php
+++ b/src/EntityRender.php
@@ -80,7 +80,7 @@ class EntityRender extends Entity {
     LanguageNegotiatorSwitcher $language_negotiator_switcher,
     ModuleHandlerInterface $module_handler,
   ) {
-    parent::__construct($entity_mesh_repository, $entity_type_manager, $language_manager, $config_factory, $module_handler);
+    parent::__construct($entity_mesh_repository, $entity_type_manager, $language_manager, $config_factory);
     $this->renderer = $renderer;
     $this->accountSwitcher = $account_switcher;
     $this->type = 'entity_render';
@@ -201,7 +201,6 @@ class EntityRender extends Entity {
 
     $pre_render = $view_builder->view($entity, $view_mode, $langcode);
 
-    /** @var \Drupal\Core\Render\RendererInterface $renderer */
     $render_output = DeprecationHelper::backwardsCompatibleCall(
       currentVersion: \Drupal::VERSION,
       deprecatedVersion: '10.3',
@@ -279,8 +278,9 @@ class EntityRender extends Entity {
    */
   protected function processInternalHref(TargetInterface $target) {
 
-    $alias = $this->entityMeshRepository->getPathWithoutLangPrefix($target->getPath());
-    $target->setEntityLangcode($this->entityMeshRepository->getLangcodeFromPath($target->getPath()));
+    $path = (string) $target->getPath();
+    $alias = $this->entityMeshRepository->getPathWithoutLangPrefix($path);
+    $target->setEntityLangcode($this->entityMeshRepository->getLangcodeFromPath($path));
 
     $found_data = $this->setDataIfRedirection($alias, $target);
 
diff --git a/src/Plugin/views/filter/BaseSelectFilter.php b/src/Plugin/views/filter/BaseSelectFilter.php
index f73fa56f4be53b3f8cf1e9ef6e0cab42c038316a..e368e3c661684dbc4100f5fa6a2361e64fffdcb9 100644
--- a/src/Plugin/views/filter/BaseSelectFilter.php
+++ b/src/Plugin/views/filter/BaseSelectFilter.php
@@ -11,7 +11,11 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
  */
 abstract class BaseSelectFilter extends InOperator implements ContainerFactoryPluginInterface {
 
-  // phpcs:ignore
+  /**
+   * Value form type.
+   *
+   * @var string
+   */
   protected $valueFormType = 'select';
 
   /**
diff --git a/src/Repository.php b/src/Repository.php
index 78b7c66b815e0aeebbb1715fb9e04b2085032384..6d3592fa75eaff113ccf701b83e269093ef9032f 100644
--- a/src/Repository.php
+++ b/src/Repository.php
@@ -11,6 +11,7 @@ use Drupal\Core\Entity\EntityTypeManagerInterface;
 use Drupal\Core\StreamWrapper\AssetsStream;
 use Drupal\file\FileInterface;
 use Drupal\media\MediaInterface;
+use Drupal\redirect\Entity\Redirect;
 use Drupal\redirect\Exception\RedirectLoopException;
 use Psr\Log\LoggerInterface;
 use Symfony\Component\HttpFoundation\RequestStack;
@@ -159,6 +160,7 @@ class Repository implements RepositoryInterface {
       $this->logger->error($e->getMessage());
       return FALSE;
     }
+
     return TRUE;
   }
 
@@ -304,10 +306,6 @@ class Repository implements RepositoryInterface {
    * {@inheritdoc}
    */
   public function saveSource(SourceInterface $source): bool {
-    // Remove source rows from the database to avoid duplicates.
-    if (!$this->deleteSource($source)) {
-      return FALSE;
-    }
     if (!$this->insertSource($source)) {
       return FALSE;
     }
@@ -414,7 +412,6 @@ class Repository implements RepositoryInterface {
     $redirect_repository = $container->get($service_redirect);
     try {
 
-      /** @var  \Drupal\redirect\Entity\Redirect $redirect_object */
       if (!empty($langcode)) {
         $redirect_object = $redirect_repository->findMatchingRedirect($path, [], $langcode);
       }
@@ -427,7 +424,7 @@ class Repository implements RepositoryInterface {
       $this->logger->error($e->getMessage());
       return NULL;
     }
-    if ($redirect_object === NULL) {
+    if (!($redirect_object instanceof Redirect)) {
       return NULL;
     }
 
@@ -461,7 +458,7 @@ class Repository implements RepositoryInterface {
   public function handlePrefixFromRedirection($uri, $langcode = '') {
     $prefixes = ['internal:', 'entity:', $langcode];
     foreach ($prefixes as $prefix) {
-      $uri = preg_replace('/^' . $prefix . '/', '', $uri);
+      $uri = (string) preg_replace('/^' . $prefix . '/', '', $uri);
       $uri = trim($uri, '/');
     }
     return $uri;
@@ -476,7 +473,7 @@ class Repository implements RepositoryInterface {
       return $path;
     }
     $path = ltrim($path, '/');
-    return str_replace($prefix, '', $path ?? '');
+    return str_replace($prefix, '', $path);
   }
 
   /**
diff --git a/tests/src/Kernel/EntityMeshEntityRenderTest.php b/tests/src/Kernel/EntityMeshEntityRenderTest.php
index 2a2e0c3208ddd0c3e1cd0ab735d368e0387e7b24..6bb7d3528fe5dfab5ad6920fca7504d19972007f 100644
--- a/tests/src/Kernel/EntityMeshEntityRenderTest.php
+++ b/tests/src/Kernel/EntityMeshEntityRenderTest.php
@@ -21,7 +21,7 @@ class EntityMeshEntityRenderTest extends KernelTestBase {
   /**
    * Modules to enable.
    *
-   * @var array
+   * @var array<string>
    */
   protected static $modules = [
     'system',
@@ -263,7 +263,8 @@ class EntityMeshEntityRenderTest extends KernelTestBase {
         'target_title',
         'target_entity_langcode',
       ]);
-    return $query->execute()->fetchAllAssoc('id', \PDO::FETCH_ASSOC);
+    $result = $query->execute();
+    return $result ? $result->fetchAllAssoc('id', \PDO::FETCH_ASSOC) : [];
   }
 
   /**