diff --git a/src/XmlSitemapLinkStorage.php b/src/XmlSitemapLinkStorage.php
index db448de..50b350b 100644
--- a/src/XmlSitemapLinkStorage.php
+++ b/src/XmlSitemapLinkStorage.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\xmlsitemap;
 
+use Drupal\Core\Database\Database;
 use Drupal\Core\Database\Query\Merge;
 use Drupal\Core\Language\LanguageInterface;
 use Drupal\Core\Extension\ModuleHandlerInterface;
@@ -49,6 +50,15 @@ class XmlSitemapLinkStorage implements XmlSitemapLinkStorageInterface {
     $this->anonymousUser = new AnonymousUserSession();
   }
 
+  /**
+   * Create the link and respective meta data and attach to entity.
+   *
+   * @param EntityInterface $entity
+   *   Entity to process.
+   *
+   * @return EntityInterface
+   *   Entity with attached xmlsitemap data.
+   */
   public function create(EntityInterface $entity) {
     if (!isset($entity->xmlsitemap)) {
       $entity->xmlsitemap = array();
@@ -58,7 +68,7 @@ class XmlSitemapLinkStorage implements XmlSitemapLinkStorageInterface {
     }
 
     $settings = xmlsitemap_link_bundle_load($entity->getEntityTypeId(), $entity->bundle());
-    $uri = $entity->url();
+    $url = $entity->toUrl();
     $entity->xmlsitemap += array(
       'type' => $entity->getEntityTypeId(),
       'id' => (string) $entity->id(),
@@ -76,9 +86,8 @@ class XmlSitemapLinkStorage implements XmlSitemapLinkStorageInterface {
       $entity->xmlsitemap['lastmod'] = $entity->getChangedTime();
     }
 
-    $url = $entity->url();
     // The following values must always be checked because they are volatile.
-    $entity->xmlsitemap['loc'] = $uri;
+    $entity->xmlsitemap['loc'] = $url;
     $entity->xmlsitemap['access'] = isset($url) && $entity->access('view', $this->anonymousUser);
     $language = $entity->language();
     $entity->xmlsitemap['language'] = !empty($language) ? $language->getId() : LanguageInterface::LANGCODE_NOT_SPECIFIED;
@@ -108,10 +117,28 @@ class XmlSitemapLinkStorage implements XmlSitemapLinkStorageInterface {
     // Temporary validation checks.
     // @todo Remove in final?
     if ($link['priority'] < 0 || $link['priority'] > 1) {
-      trigger_error(t('Invalid sitemap link priority %priority.<br />@link', array('%priority' => $link['priority'], '@link' => var_export($link, TRUE))), E_USER_ERROR);
+      trigger_error(
+        t(
+          'Invalid sitemap link priority %priority.<br />:link',
+          [
+            '%priority' => $link['priority'],
+            ':link' => var_export($link, TRUE),
+          ]
+        ),
+        E_USER_ERROR
+      );
     }
     if ($link['changecount'] < 0) {
-      trigger_error(t('Negative changecount value. Please report this to <a href="@516928">@516928</a>.<br />@link', array('@516928' => 'http://drupal.org/node/516928', '@link' => var_export($link, TRUE))), E_USER_ERROR);
+      trigger_error(
+        t(
+          'Negative changecount value. Please report this to <a href=":516928">:516928</a>.<br />:link',
+          [
+            ':516928' => 'http://drupal.org/node/516928',
+            ':link' => var_export($link, TRUE),
+          ]
+        ),
+        E_USER_ERROR
+      );
       $link['changecount'] = 0;
     }
 
@@ -137,8 +164,7 @@ class XmlSitemapLinkStorage implements XmlSitemapLinkStorageInterface {
       ))
       ->execute();
 
-    switch($queryStatus)
-    {
+    switch ($queryStatus) {
       case Merge::STATUS_INSERT:
         $this->moduleHandler->invokeAll('xmlsitemap_link_insert', array($link));
         break;
@@ -159,7 +185,9 @@ class XmlSitemapLinkStorage implements XmlSitemapLinkStorageInterface {
 
     if ($original_link === NULL) {
       // Load only the fields necessary for data to be changed in the sitemap.
-      $original_link = db_query_range("SELECT loc, access, status, lastmod, priority, changefreq, changecount, language FROM {xmlsitemap} WHERE type = :type AND id = :id", 0, 1, array(':type' => $link['type'], ':id' => $link['id']))->fetchAssoc();
+      $original_link = Database::getConnection()
+        ->queryRange("SELECT loc, access, status, lastmod, priority, changefreq, changecount, language FROM {xmlsitemap} WHERE type = :type AND id = :id", 0, 1, [':type' => $link['type'], ':id' => $link['id']])
+        ->fetchAssoc();
     }
 
     if (!$original_link) {
@@ -174,7 +202,7 @@ class XmlSitemapLinkStorage implements XmlSitemapLinkStorageInterface {
         $changed = TRUE;
       }
       elseif ($original_link['access'] && $original_link['status'] && array_diff_assoc($original_link, $link)) {
-        // Changing a visible link
+        // Changing a visible link.
         $changed = TRUE;
       }
     }
@@ -194,7 +222,7 @@ class XmlSitemapLinkStorage implements XmlSitemapLinkStorageInterface {
     $conditions['status'] = (!empty($updates['status']) && empty($conditions['status'])) ? 0 : 1;
     $conditions['access'] = (!empty($updates['access']) && empty($conditions['access'])) ? 0 : 1;
 
-    $query = db_select('xmlsitemap');
+    $query = Database::getConnection()->select('xmlsitemap');
     $query->addExpression('1');
     foreach ($conditions as $field => $value) {
       $query->condition($field, $value);
@@ -226,7 +254,7 @@ class XmlSitemapLinkStorage implements XmlSitemapLinkStorageInterface {
     }
 
     // @todo Add a hook_xmlsitemap_link_delete() hook invoked here.
-    $query = db_delete('xmlsitemap');
+    $query = Database::getConnection()->delete('xmlsitemap');
     foreach ($conditions as $field => $value) {
       $query->condition($field, $value);
     }
@@ -245,7 +273,7 @@ class XmlSitemapLinkStorage implements XmlSitemapLinkStorageInterface {
     }
 
     // Process updates.
-    $query = db_update('xmlsitemap');
+    $query = Database::getConnection()->update('xmlsitemap');
     $query->fields($updates);
     foreach ($conditions as $field => $value) {
       $query->condition($field, $value);
@@ -266,7 +294,7 @@ class XmlSitemapLinkStorage implements XmlSitemapLinkStorageInterface {
    * {@inheritdoc}
    */
   public function loadMultiple(array $conditions = array()) {
-    $query = db_select('xmlsitemap');
+    $query = Database::getConnection()->select('xmlsitemap');
     $query->fields('xmlsitemap');
 
     foreach ($conditions as $field => $value) {
