diff --git a/composer.json b/composer.json
index 32b0629..daef2eb 100644
--- a/composer.json
+++ b/composer.json
@@ -18,5 +18,12 @@
     "source": "http://git.drupal.org/project/linkchecker.git"
   },
   "license": "GPL-2.0+",
-  "require": {}
+  "require": {},
+  "extra": {
+    "drush": {
+      "services": {
+        "drush.services.yml": "^9"
+      }
+    }
+  }
 }
diff --git a/drush.services.yml b/drush.services.yml
new file mode 100644
index 0000000..efe67ef
--- /dev/null
+++ b/drush.services.yml
@@ -0,0 +1,8 @@
+services:
+  linkcker.command:
+    class: Drupal\linkchecker\Commands\LinkcheckerCommands
+    arguments:
+      - '@config.factory'
+      - '@logger.channel.linkchecker'
+    tags:
+      - { name: drush.command }
\ No newline at end of file
diff --git a/linkchecker.batch.inc b/linkchecker.batch.inc
index b8af795..bb29932 100644
--- a/linkchecker.batch.inc
+++ b/linkchecker.batch.inc
@@ -8,20 +8,20 @@
 /**
  * Batch: Scan nodes for links.
  */
-function _linkchecker_batch_import_nodes($node_types = array()) {
+function _linkchecker_batch_import_nodes($node_types = []) {
   // Get all active {node}.nid's.
-  $result = db_query('SELECT n.nid FROM {node} n WHERE n.status = :status AND n.type IN (:types) ORDER BY n.nid', array(':status' => 1, ':types' => $node_types));
+  $result = db_query('SELECT n.nid FROM {node} n WHERE n.status = :status AND n.type IN (:types) ORDER BY n.nid', [':status' => 1, ':types' => $node_types]);
 
-  $operations = array();
+  $operations = [];
   foreach ($result as $row) {
-    $operations[] = array('_linkchecker_batch_node_import_op', array($row->nid));
+    $operations[] = ['_linkchecker_batch_node_import_op', [$row->nid]];
   }
-  $batch = array(
+  $batch = [
     'file' => drupal_get_path('module', 'linkchecker') . '/linkchecker.batch.inc',
     'finished' => '_linkchecker_batch_node_import_finished',
     'operations' => $operations,
     'title' => t('Scanning for links'),
-  );
+  ];
 
   return $batch;
 }
@@ -36,7 +36,7 @@ function _linkchecker_batch_node_import_op($nid, &$context) {
 
   // Store results for post-processing in the finished callback.
   $context['results'][] = $node->nid;
-  $context['message'] = t('Content: @title', array('@title' => $node->title));
+  $context['message'] = t('Content: @title', ['@title' => $node->title]);
 }
 
 /**
@@ -62,20 +62,20 @@ function _linkchecker_batch_node_import_finished($success, $results, $operations
 /**
  * Batch: Scan comments for links.
  */
-function _linkchecker_batch_import_comments($node_types = array()) {
+function _linkchecker_batch_import_comments($node_types = []) {
   // Get all active {comment}.cid's.
-  $result = db_query('SELECT c.cid FROM {comment} c INNER JOIN {node} n ON c.nid = n.nid WHERE c.status = :cstatus AND n.status = :nstatus AND n.type IN (:types) ORDER BY c.cid', array(':cstatus' => COMMENT_PUBLISHED, ':nstatus' => 1, ':types' => $node_types));
+  $result = db_query('SELECT c.cid FROM {comment} c INNER JOIN {node} n ON c.nid = n.nid WHERE c.status = :cstatus AND n.status = :nstatus AND n.type IN (:types) ORDER BY c.cid', [':cstatus' => COMMENT_PUBLISHED, ':nstatus' => 1, ':types' => $node_types]);
 
-  $operations = array();
+  $operations = [];
   foreach ($result as $row) {
-    $operations[] = array('_linkchecker_batch_comments_import_op', array($row->cid));
+    $operations[] = ['_linkchecker_batch_comments_import_op', [$row->cid]];
   }
-  $batch = array(
+  $batch = [
     'file' => drupal_get_path('module', 'linkchecker') . '/linkchecker.batch.inc',
     'finished' => '_linkchecker_batch_comments_import_finished',
     'operations' => $operations,
     'title' => t('Scanning for links'),
-  );
+  ];
 
   return $batch;
 }
@@ -90,7 +90,7 @@ function _linkchecker_batch_comments_import_op($cid, &$context) {
 
   // Store results for post-processing in the finished callback.
   $context['results'][] = $comment->cid;
-  $context['message'] = t('Comment: @title', array('@title' => $comment->subject));
+  $context['message'] = t('Comment: @title', ['@title' => $comment->subject]);
 }
 
 /**
@@ -103,7 +103,7 @@ function _linkchecker_batch_comments_import_op($cid, &$context) {
  * @param array $operations
  *   Array of functions called.
  */
-function _linkchecker_batch_comments_import_finished($success, $results, $operations) {
+function _linkchecker_batch_comments_import_finished($success, $results, array $operations) {
   if ($success) {
     $message = format_plural(count($results), 'One comment has been scanned.', '@count comments have been scanned.');
   }
@@ -120,16 +120,16 @@ function _linkchecker_batch_import_block_custom() {
   // Get all {block_custom}.bid's as block module suxxx and has no usable hooks.
   $result = db_query('SELECT bid FROM {block_custom} ORDER BY bid');
 
-  $operations = array();
+  $operations = [];
   foreach ($result as $row) {
-    $operations[] = array('_linkchecker_batch_import_block_custom_op', array($row->bid));
+    $operations[] = ['_linkchecker_batch_import_block_custom_op', [$row->bid]];
   }
-  $batch = array(
+  $batch = [
     'file' => drupal_get_path('module', 'linkchecker') . '/linkchecker.batch.inc',
     'finished' => '_linkchecker_batch_block_custom_import_finished',
     'operations' => $operations,
     'title' => t('Scanning for links'),
-  );
+  ];
 
   return $batch;
 }
@@ -144,7 +144,7 @@ function _linkchecker_batch_import_block_custom_op($bid, &$context) {
 
   // Store some result for post-processing in the finished callback.
   $context['results'][] = $block_custom->delta;
-  $context['message'] = t('Block: @title', array('@title' => $block_custom->info));
+  $context['message'] = t('Block: @title', ['@title' => $block_custom->info]);
 }
 
 /**
@@ -157,7 +157,7 @@ function _linkchecker_batch_import_block_custom_op($bid, &$context) {
  * @param array $operations
  *   Array of functions called.
  */
-function _linkchecker_batch_block_custom_import_finished($success, $results, $operations) {
+function _linkchecker_batch_block_custom_import_finished($success, $results, array $operations) {
   if ($success) {
     $message = format_plural(count($results), 'One block has been scanned.', '@count blocks have been scanned.');
   }
@@ -180,17 +180,17 @@ function _linkchecker_batch_block_custom_import_finished($success, $results, $op
  *   The batch task definition.
  */
 function _linkchecker_batch_import_single_node($nid, $missing_links_count) {
-  $operations = array();
+  $operations = [];
   for ($i = 0; $i <= $missing_links_count; $i = $i + LINKCHECKER_SCAN_MAX_LINKS_PER_RUN) {
-    $operations[] = array('_linkchecker_batch_single_node_import_op', array($nid));
+    $operations[] = ['_linkchecker_batch_single_node_import_op', [$nid]];
   }
-  $batch = array(
+  $batch = [
     'file' => drupal_get_path('module', 'linkchecker') . '/linkchecker.batch.inc',
     'finished' => '_linkchecker_batch_single_node_import_finished',
     'operations' => $operations,
     'title' => t('Scanning for links'),
     'progress_message' => t('Remaining @remaining of @total scans.'),
-  );
+  ];
 
   return $batch;
 }
@@ -203,14 +203,14 @@ function _linkchecker_batch_import_single_node($nid, $missing_links_count) {
  * @param array $context
  *   Batch context array.
  */
-function _linkchecker_batch_single_node_import_op($nid, &$context) {
+function _linkchecker_batch_single_node_import_op($nid, array &$context) {
   // Load the node and scan for links.
   $node = node_load($nid, NULL, TRUE);
   _linkchecker_add_node_links($node, TRUE);
 
   // Store results for post-processing in the finished callback.
   $context['results'][] = $node->nid;
-  $context['message'] = t('Content: @title', array('@title' => $node->title));
+  $context['message'] = t('Content: @title', ['@title' => $node->title]);
 }
 
 /**
@@ -223,12 +223,12 @@ function _linkchecker_batch_single_node_import_op($nid, &$context) {
  * @param array $operations
  *   Array of functions called.
  */
-function _linkchecker_batch_single_node_import_finished($success, $results, $operations) {
+function _linkchecker_batch_single_node_import_finished($success, $results, array $operations) {
   if ($success) {
-    $message = format_plural(count($results), 'Node @nid has been re-scanned once to collect all links.', 'Node @nid has been re-scanned @count times to collect all links.', array('@nid' => $results[0]));
+    $message = format_plural(count($results), 'Node @nid has been re-scanned once to collect all links.', 'Node @nid has been re-scanned @count times to collect all links.', ['@nid' => $results[0]]);
   }
   else {
-    $message = t('Recurring scanning for links in node @nid has failed with an error.', array('@nid' => $results[0]));
+    $message = t('Recurring scanning for links in node @nid has failed with an error.', ['@nid' => $results[0]]);
   }
   drupal_set_message($message);
 }
@@ -246,17 +246,17 @@ function _linkchecker_batch_single_node_import_finished($success, $results, $ope
  *   The batch task definition.
  */
 function _linkchecker_batch_import_single_comment($cid, $missing_links_count) {
-  $operations = array();
+  $operations = [];
   for ($i = 0; $i <= $missing_links_count; $i = $i + LINKCHECKER_SCAN_MAX_LINKS_PER_RUN) {
-    $operations[] = array('_linkchecker_batch_single_comment_import_op', array($cid));
+    $operations[] = ['_linkchecker_batch_single_comment_import_op', [$cid]];
   }
-  $batch = array(
+  $batch = [
     'file' => drupal_get_path('module', 'linkchecker') . '/linkchecker.batch.inc',
     'finished' => '_linkchecker_batch_single_comment_import_finished',
     'operations' => $operations,
     'title' => t('Scanning for links'),
     'progress_message' => t('Remaining @remaining of @total scans.'),
-  );
+  ];
 
   return $batch;
 }
@@ -269,13 +269,13 @@ function _linkchecker_batch_import_single_comment($cid, $missing_links_count) {
  * @param array $context
  *   Batch context array.
  */
-function _linkchecker_batch_single_comment_import_op($cid, &$context) {
+function _linkchecker_batch_single_comment_import_op($cid, array &$context) {
   $comment = comment_load($cid);
   _linkchecker_add_comment_links($comment, TRUE);
 
   // Store results for post-processing in the finished callback.
   $context['results'][] = $comment->cid;
-  $context['message'] = t('Comment: @title', array('@title' => $comment->subject));
+  $context['message'] = t('Comment: @title', ['@title' => $comment->subject]);
 }
 
 /**
@@ -288,12 +288,12 @@ function _linkchecker_batch_single_comment_import_op($cid, &$context) {
  * @param array $operations
  *   Array of functions called.
  */
-function _linkchecker_batch_single_comment_import_finished($success, $results, $operations) {
+function _linkchecker_batch_single_comment_import_finished($success, $results, array $operations) {
   if ($success) {
-    $message = format_plural(count($results), 'Comment @cid has been re-scanned once to collect all links.', 'Comment @cid has been re-scanned @count times to collect all links.', array('@cid' => $results[0]));
+    $message = format_plural(count($results), 'Comment @cid has been re-scanned once to collect all links.', 'Comment @cid has been re-scanned @count times to collect all links.', ['@cid' => $results[0]]);
   }
   else {
-    $message = t('Recurring scanning for links in comment @cid has failed with an error.', array('@cid' => $results[0]));
+    $message = t('Recurring scanning for links in comment @cid has failed with an error.', ['@cid' => $results[0]]);
   }
   drupal_set_message($message);
 }
@@ -311,17 +311,17 @@ function _linkchecker_batch_single_comment_import_finished($success, $results, $
  *   The batch task definition.
  */
 function _linkchecker_batch_import_single_block_custom($bid, $missing_links_count) {
-  $operations = array();
+  $operations = [];
   for ($i = 0; $i <= $missing_links_count; $i = $i + LINKCHECKER_SCAN_MAX_LINKS_PER_RUN) {
-    $operations[] = array('_linkchecker_batch_single_block_custom_import_op', array($bid));
+    $operations[] = ['_linkchecker_batch_single_block_custom_import_op', [$bid]];
   }
-  $batch = array(
+  $batch = [
     'file' => drupal_get_path('module', 'linkchecker') . '/linkchecker.batch.inc',
     'finished' => '_linkchecker_batch_single_block_custom_import_finished',
     'operations' => $operations,
     'title' => t('Scanning for links'),
     'progress_message' => t('Remaining @remaining of @total scans.'),
-  );
+  ];
 
   return $batch;
 }
@@ -334,14 +334,14 @@ function _linkchecker_batch_import_single_block_custom($bid, $missing_links_coun
  * @param array $context
  *   Batch context array.
  */
-function _linkchecker_batch_single_block_custom_import_op($bid, &$context) {
+function _linkchecker_batch_single_block_custom_import_op($bid, array &$context) {
   // Load the custom block and scan for links.
   $block_custom = linkchecker_block_custom_block_get($bid);
   _linkchecker_add_block_custom_links($block_custom, $block_custom->delta, TRUE);
 
   // Store some result for post-processing in the finished callback.
   $context['results'][] = $block_custom->delta;
-  $context['message'] = t('Block: @title', array('@title' => $block_custom->info));
+  $context['message'] = t('Block: @title', ['@title' => $block_custom->info]);
 }
 
 /**
@@ -354,12 +354,12 @@ function _linkchecker_batch_single_block_custom_import_op($bid, &$context) {
  * @param array $operations
  *   Array of functions called.
  */
-function _linkchecker_batch_single_block_custom_import_finished($success, $results, $operations) {
+function _linkchecker_batch_single_block_custom_import_finished($success, $results, array $operations) {
   if ($success) {
-    $message = format_plural(count($results), 'Block @bid has been re-scanned once to collect all links.', 'Block @bid has been re-scanned @count times to collect all links.', array('@bid' => $results[0]));
+    $message = format_plural(count($results), 'Block @bid has been re-scanned once to collect all links.', 'Block @bid has been re-scanned @count times to collect all links.', ['@bid' => $results[0]]);
   }
   else {
-    $message = t('Recurring scanning for links in block @bid has failed with an error.', array('@bid' => $results[0]));
+    $message = t('Recurring scanning for links in block @bid has failed with an error.', ['@bid' => $results[0]]);
   }
   drupal_set_message($message);
 }
diff --git a/linkchecker.install b/linkchecker.install
index 8a9c3ce..df973fc 100644
--- a/linkchecker.install
+++ b/linkchecker.install
@@ -20,156 +20,156 @@ function linkchecker_install() {
  */
 function linkchecker_schema() {
 
-  $schema['linkchecker_block_custom'] = array(
+  $schema['linkchecker_block_custom'] = [
     'description' => 'Stores all link references for custom blocks.',
-    'fields' => array(
-      'bid'  => array(
+    'fields' => [
+      'bid'  => [
         'type' => 'int',
         'not null' => TRUE,
         'description' => 'Primary Key: Unique {block_custom}.bid.',
-      ),
-      'lid' => array(
+      ],
+      'lid' => [
         'type' => 'int',
         'not null' => TRUE,
         'description' => 'Primary Key: Unique {linkchecker_link}.lid.',
-      ),
-    ),
-    'primary key' => array('bid', 'lid'),
-    'foreign keys' => array(
-      'bid' => array(
+      ],
+    ],
+    'primary key' => ['bid', 'lid'],
+    'foreign keys' => [
+      'bid' => [
         'table' => 'block_custom',
-        'columns' => array('bid' => 'bid'),
-      ),
-      'lid' => array(
+        'columns' => ['bid' => 'bid'],
+      ],
+      'lid' => [
         'table' => 'linkchecker_link',
-        'columns' => array('lid' => 'lid'),
-      ),
-    ),
-    'indexes' => array('lid' => array('lid')),
-  );
+        'columns' => ['lid' => 'lid'],
+      ],
+    ],
+    'indexes' => ['lid' => ['lid']],
+  ];
 
-  $schema['linkchecker_comment'] = array(
+  $schema['linkchecker_comment'] = [
     'description' => 'Stores all link references for comments.',
-    'fields' => array(
-      'cid'  => array(
+    'fields' => [
+      'cid'  => [
         'type' => 'int',
         'not null' => TRUE,
         'description' => 'Primary Key: Unique {comment}.cid.',
-      ),
-      'lid' => array(
+      ],
+      'lid' => [
         'type' => 'int',
         'not null' => TRUE,
         'description' => 'Primary Key: Unique {linkchecker_link}.lid.',
-      ),
-    ),
-    'primary key' => array('cid', 'lid'),
-    'foreign keys' => array(
-      'cid' => array(
+      ],
+    ],
+    'primary key' => ['cid', 'lid'],
+    'foreign keys' => [
+      'cid' => [
         'table' => 'comment',
-        'columns' => array('cid' => 'cid'),
-      ),
-      'lid' => array(
+        'columns' => ['cid' => 'cid'],
+      ],
+      'lid' => [
         'table' => 'linkchecker_link',
-        'columns' => array('lid' => 'lid'),
-      ),
-    ),
-    'indexes' => array('lid' => array('lid')),
-  );
+        'columns' => ['lid' => 'lid'],
+      ],
+    ],
+    'indexes' => ['lid' => ['lid']],
+  ];
 
-  $schema['linkchecker_node'] = array(
+  $schema['linkchecker_node'] = [
     'description' => 'Stores all link references for nodes.',
-    'fields' => array(
-      'nid'  => array(
+    'fields' => [
+      'nid'  => [
         'type' => 'int',
         'not null' => TRUE,
         'description' => 'Primary Key: Unique {node}.nid.',
-      ),
-      'lid' => array(
+      ],
+      'lid' => [
         'type' => 'int',
         'not null' => TRUE,
         'description' => 'Primary Key: Unique {linkchecker_link}.lid.',
-      ),
-    ),
-    'primary key' => array('nid', 'lid'),
-    'foreign keys' => array(
-      'nid' => array(
+      ],
+    ],
+    'primary key' => ['nid', 'lid'],
+    'foreign keys' => [
+      'nid' => [
         'table' => 'node',
-        'columns' => array('nid' => 'nid'),
-      ),
-      'lid' => array(
+        'columns' => ['nid' => 'nid'],
+      ],
+      'lid' => [
         'table' => 'linkchecker_link',
-        'columns' => array('lid' => 'lid'),
-      ),
-    ),
-    'indexes' => array('lid' => array('lid')),
-  );
+        'columns' => ['lid' => 'lid'],
+      ],
+    ],
+    'indexes' => ['lid' => ['lid']],
+  ];
 
-  $schema['linkchecker_link'] = array(
+  $schema['linkchecker_link'] = [
     'description' => 'Stores all links.',
-    'fields' => array(
-      'lid'  => array(
+    'fields' => [
+      'lid'  => [
         'type' => 'serial',
         'not null' => TRUE,
         'description' => 'Primary Key: Unique link ID.',
-      ),
-      'urlhash' => array(
+      ],
+      'urlhash' => [
         'type' => 'varchar',
         'length' => 64,
         'not null' => TRUE,
         'description' => 'The indexable hash of the {linkchecker_link}.url.',
-      ),
-      'url' => array(
+      ],
+      'url' => [
         'type' => 'text',
         'not null' => TRUE,
         'description' => 'The full qualified link.',
-      ),
-      'method' => array(
+      ],
+      'method' => [
         'type' => 'varchar',
         'length' => 4,
         'default' => 'HEAD',
         'not null' => TRUE,
         'description' => 'The method for checking links (HEAD, GET, POST).',
-      ),
-      'code' => array(
+      ],
+      'code' => [
         'type' => 'int',
         'not null' => TRUE,
         'default' => -1,
         'description' => 'HTTP status code from link checking.',
-      ),
-      'error' => array(
+      ],
+      'error' => [
         'type' => 'text',
         'not null' => FALSE,
         'description' => 'The error message received from the remote server while doing link checking.',
-      ),
-      'fail_count' => array(
+      ],
+      'fail_count' => [
         'type' => 'int',
         'not null' => TRUE,
         'default' => 0,
         'description' => 'Fail count of unsuccessful link checks. No flapping detection. (Successful = 0, Unsuccessful = fail_count+1).',
-      ),
-      'last_checked' => array(
+      ],
+      'last_checked' => [
         'type' => 'int',
         'not null' => TRUE,
         'default' => 0,
         'description' => 'Timestamp of the last link check.',
-      ),
-      'status' => array(
+      ],
+      'status' => [
         'type' => 'int',
         'not null' => TRUE,
         'default' => 1,
         'description' => 'Boolean indicating if a link should be checked or not.',
-      ),
-    ),
-    'primary key' => array('lid'),
-    'unique keys' => array('urlhash' => array('urlhash')),
-    'indexes' => array(
-      'method' => array('method'),
-      'code' => array('code'),
-      'fail_count' => array('fail_count'),
-      'last_checked' => array('last_checked'),
-      'status' => array('status'),
-    ),
-  );
+      ],
+    ],
+    'primary key' => ['lid'],
+    'unique keys' => ['urlhash' => ['urlhash']],
+    'indexes' => [
+      'method' => ['method'],
+      'code' => ['code'],
+      'fail_count' => ['fail_count'],
+      'last_checked' => ['last_checked'],
+      'status' => ['status'],
+    ],
+  ];
 
   return $schema;
 }
@@ -182,7 +182,7 @@ function linkchecker_schema() {
 function linkchecker_modules_uninstalled($modules) {
   // Disable link checks for custom blocks.
   if (in_array('block', $modules)) {
-    \Drupal::config('linkchecker.settings')->set('scan_blocks', 0);
+    \Drupal::config('linkchecker.settings')->set('scan_blocks');
     drupal_set_message(t('Link checks for blocks have been disabled.'));
   }
 
@@ -190,9 +190,9 @@ function linkchecker_modules_uninstalled($modules) {
   if (in_array('comment', $modules)) {
     foreach (node_type_get_names() as $type => $name) {
       // @fixme: This is incorrect. The variable is inside node.type.*.third_party.linkchecker
-      //\Drupal::config('node.type.' . $type .  '.third_party.linkchecker')->clear('scan_comment');
-      //\Drupal::service('config.manager');
-      //$type->unsetThirdPartySetting('linkchecker', 'scan_comment', $form_state->getValue('scan_comment'));
+      // \Drupal::config('node.type.' . $type .  '.third_party.linkchecker')->clear('scan_comment');
+      // \Drupal::service('config.manager');
+      // $type->unsetThirdPartySetting('linkchecker', 'scan_comment', $form_state->getValue('scan_comment'));
     }
     drupal_set_message(t('Link checks for comments have been disabled.'));
   }
diff --git a/linkchecker.module b/linkchecker.module
index fdc7d23..024cfcf 100644
--- a/linkchecker.module
+++ b/linkchecker.module
@@ -7,12 +7,27 @@
  * Developed by Alexander Hass, http://www.yaml-for-drupal.com/.
  */
 
+use Drupal\Component\Utility\Crypt;
+use Drupal\Component\Utility\Html;
+use Drupal\Component\Utility\Unicode;
+use Drupal\Component\Utility\UrlHelper;
+use Drupal\Component\Utility\Timer;
+use Drupal\Core\Database\Database;
 use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Logger\RfcLogLevel;
 use Drupal\Core\Routing\RouteMatchInterface;
+use Drupal\Core\Session\AccountInterface;
 use Drupal\Core\Session\UserSession;
+use Drupal\Core\Url;
+use Drupal\field\FieldConfigInterface;
+use Drupal\filter\Entity;
+use Drupal\field\Entity\FieldStorageConfig;
+use Drupal\filter\Entity\FilterFormat;
+use Drupal\node\Entity\Node;
+use Drupal\node\Entity\NodeType;
+use Drupal\node\NodeInterface;
 use Drupal\node\NodeTypeInterface;
-use GuzzleHttp\Exception\RequestException;
-
+use GuzzleHttp\Exception\ClientException;
 
 /**
  * Defines the maximum limit of links collected in one chunk if content is
@@ -96,11 +111,11 @@ function linkchecker_help($route_name, RouteMatchInterface $route_match) {
  *   The severity of the message; one of the following values as defined in
  *   @link http://www.faqs.org/rfcs/rfc3164.html RFC 3164: @endlink
  *   - WATCHDOG_EMERGENCY: Emergency, system is unusable.
- *   - WATCHDOG_ALERT: Alert, action must be taken immediately.
- *   - WATCHDOG_CRITICAL: Critical conditions.
+ *   - RfcLogLevel::ALERT: Alert, action must be taken immediately.
+ *   - RfcLogLevel::CRITICAL: Critical conditions.
  *   - WATCHDOG_ERROR: Error conditions.
  *   - WATCHDOG_WARNING: Warning conditions.
- *   - WATCHDOG_NOTICE: (default) Normal but significant conditions.
+ *   - RfcLogLevel::NOTICE: (default) Normal but significant conditions.
  *   - WATCHDOG_INFO: Informational messages.
  *   - WATCHDOG_DEBUG: Debug-level messages.
  * @param $link
@@ -109,9 +124,10 @@ function linkchecker_help($route_name, RouteMatchInterface $route_match) {
  * @see watchdog_severity_levels()
  * @see watchdog()
  */
-function linkchecker_watchdog_log($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = NULL) {
-  if ($severity <= variable_get('linkchecker_log_level', WATCHDOG_INFO)) {
-    watchdog($type, $message, $variables, $severity, $link);
+function linkchecker_watchdog_log($type, $message, $variables = [], $severity = RfcLogLevel::NOTICE, $link = NULL) {
+  if ($severity <= \Drupal::config('linkchecker.settings')->get('logging.level')) {
+    $logger = \Drupal::logger($type);
+    $logger->log($severity, $message, $variables);
   }
 }
 
@@ -124,12 +140,11 @@ function linkchecker_watchdog_log($type, $message, $variables = array(), $severi
  * @return int|bool
  */
 function _linkchecker_user_access_account_broken_links_report($account) {
-  global $user;
-
+  $user = \Drupal::currentUser();
   // Users with 'access own broken links report' permission can only view their
   // own report. Users with the 'access broken links report' permission can
   // view the report for any authenticated user.
-  return $account->uid && (($user->uid == $account->uid && user_access('access own broken links report')) || user_access('access broken links report'));
+  return $account->uid && (($user->uid == $account->uid && \Drupal::currentUser()->hasPermission('access own broken links report')) || \Drupal::currentUser()->hasPermission('access broken links report'));
 }
 
 /**
@@ -142,7 +157,9 @@ function _linkchecker_user_access_account_broken_links_report($account) {
  *   TRUE if the current user has the requested permission.
  */
 function _linkchecker_user_access_edit_link_settings($link) {
-  return user_access('edit link settings') && _linkchecker_link_access($link);
+
+  return \Drupal::currentUser()->hasPermission('edit link settings') && _linkchecker_link_access($link);
+
 }
 
 /**
@@ -188,79 +205,81 @@ function _linkchecker_link_access($link) {
  *   user may be allowed to view.
  */
 function _linkchecker_link_node_ids($link, $node_author_account = NULL) {
-  static $fields_with_node_links = array();
+  static $fields_with_node_links = [];
 
   // Exit if all node types are disabled or if the user cannot access content,
   // there is no need to check further.
   $linkchecker_scan_nodetypes = linkchecker_scan_node_types();
-  if (empty($linkchecker_scan_nodetypes) || !user_access('access content')) {
-    return array();
+  if (empty($linkchecker_scan_nodetypes) || !\Drupal::currentUser()->hasPermission('access content')) {
+    return [];
   }
 
   // Get a list of nodes containing the link, using addTag('node_access') to
   // allow node access modules to exclude nodes that the current user does not
   // have access to view.
   if (!empty($node_author_account)) {
-    $query = db_select('node', 'n');
+
+    $query = \Drupal::database()->select('node', 'n');
     $query->addTag('node_access');
     $query->innerJoin('linkchecker_node', 'ln', 'ln.nid = n.nid');
     $query->innerJoin('node_revision', 'r', 'r.vid = n.vid');
     $query->condition('ln.lid', $link->lid);
-    $query->condition(db_or()
-      ->condition('n.uid', $node_author_account->uid)
-      ->condition('r.uid', $node_author_account->uid)
-    );
-    $query->fields('n', array('nid'));
+    $or_condition_group = $query->orConditionGroup()
+      ->condition('n.uid', $node_author_account->id())
+      ->condition('r.uid', $node_author_account->id());
+    $query->condition($or_condition_group);
+
+    $query->fields('n', ['nid']);
   }
   else {
-    $query = db_select('node', 'n');
+    $query = \Drupal::database()->select('node', 'n');
     $query->addTag('node_access');
     $query->innerJoin('linkchecker_node', 'ln', 'ln.nid = n.nid');
     $query->condition('ln.lid', $link->lid);
-    $query->fields('n', array('nid'));
+    $query->fields('n', ['nid']);
   }
   $nodes = $query->execute();
 
   // Check if the current user has access to view the link in each node.
   // However, for performance reasons, as soon as we find one node where that
   // is the case, stop checking and return the remainder of the list.
-  $nids = array();
+  $nids = [];
   $access_allowed = FALSE;
   foreach ($nodes as $node) {
     if ($access_allowed) {
-      $nids[] = $node->nid;
+      $nids[] = $node->id();
       continue;
     }
-    $node = node_load($node->nid);
+    $node = Node::load($node->id());
 
     // We must check whether the link is currently part of the node; if not, we
     // do not want to return it (and it is not safe to, since we cannot know if
     // it contained access restrictions for the current user at the point which
     // it was originally extracted by the Link checker module).
-    if (!isset($fields_with_node_links[$node->nid])) {
-      $fields_with_node_links[$node->nid] = _linkchecker_extract_node_links($node, TRUE);
+    if (!isset($fields_with_node_links[$node->id()])) {
+      $fields_with_node_links[$node->id()] = _linkchecker_extract_node_links($node, TRUE);
     }
-    if (empty($fields_with_node_links[$node->nid][$link->url])) {
+    if (empty($fields_with_node_links[$node->id()][$link->url])) {
       continue;
     }
     // If the link appears in fields and a field access module is being used,
     // we must check that the current user has access to view at least one field
     // that contains the link; if they don't, we should not return the node.
-    $fields = $fields_with_node_links[$node->nid][$link->url];
-    if (module_implements('field_access')) {
-      $fields_with_access = array();
+    $fields = $fields_with_node_links[$node->id()][$link->url];
+    if (\Drupal::moduleHandler()->getImplementations('field_access')) {
+      $fields_with_access = [];
 
-      $bundle_instances = field_info_instances('node', $node->type);
+      $bundle_instances = field_info_instances('node', $node->bundle());
       foreach ($bundle_instances as $field_name => $field_instance) {
         $field = field_info_field($field_name);
 
         // Field types supported by linkchecker.
-        $fields_supported = array(
+        $fields_supported = [
           'text_with_summary',
           'text_long',
           'text',
           'link_field',
-        );
+        ];
 
         // Only check link and text fields, since those are the only types we
         // extract links from.
@@ -272,7 +291,7 @@ function _linkchecker_link_node_ids($link, $node_author_account = NULL) {
         continue;
       }
     }
-    $nids[] = $node->nid;
+    $nids[] = $node->id();
     $access_allowed = TRUE;
   }
 
@@ -297,29 +316,29 @@ function _linkchecker_link_comment_ids($link, $comment_author_account = NULL) {
   // Exit if comments are disabled or if the user cannot access comments, there
   // is no need to check further.
   $comment_types = linkchecker_scan_comment_types();
-  if (empty($comment_types) || !user_access('access comments')) {
-    return array();
+  if (empty($comment_types) || !\Drupal::currentUser()->hasPermission('access comments')) {
+    return [];
   }
 
   // Get a list of comments containing the link, using addTag('node_access') to
   // allow comment access modules to exclude comments that the current user
   // does not have access to view.
   if (!empty($comment_author_account)) {
-    $query = db_select('comment', 'c');
+    $query = \Drupal::database()->select('comment', 'c');
     $query->addMetaData('base_table', 'comment');
     $query->addTag('node_access');
     $query->innerJoin('linkchecker_comment', 'lc', 'lc.cid = c.cid');
     $query->condition('lc.lid', $link->lid);
     $query->condition('c.uid', $comment_author_account->uid);
-    $query->fields('c', array('cid'));
+    $query->fields('c', ['cid']);
   }
   else {
-    $query = db_select('comment', 'c');
+    $query = \Drupal::database()->select('comment', 'c');
     $query->addMetaData('base_table', 'comment');
     $query->addTag('node_access');
     $query->innerJoin('linkchecker_comment', 'lc', 'lc.cid = c.cid');
     $query->condition('lc.lid', $link->lid);
-    $query->fields('c', array('cid'));
+    $query->fields('c', ['cid']);
   }
   $cids = $query->execute()->fetchCol();
 
@@ -338,33 +357,35 @@ function _linkchecker_link_comment_ids($link, $comment_author_account = NULL) {
  *   current user is allowed to view.
  */
 function _linkchecker_link_block_ids($link) {
+  $user = Drupal::currentUser();
   // Exit if blocks are disabled.
-  if (!variable_get('linkchecker_scan_blocks', 0)) {
-    return array();
+  if (!\Drupal::config('linkchecker.settings')->get('scan_blocks')) {
+    return [];
   }
 
   // Get the initial list of block IDs.
-  $bids = db_query('SELECT bid FROM {linkchecker_block_custom} WHERE lid = :lid', array(':lid' => $link->lid))->fetchCol();
+  $connection = \Drupal::database();
+  $query = $connection->query('SELECT bid FROM {linkchecker_block_custom} WHERE lid = :lid', [':lid' => $link->lid]);
+  $bids = $query->fetchCol();
 
   // If the user can administer blocks, they're able to see all block content.
-  if (user_access('administer blocks')) {
+  if ($user->hasPermission('administer blocks')) {
     return $bids;
   }
 
   // Otherwise, only return blocks that this user (or anonymous users) have
   // access to.
-  global $user;
-  $rids = array_keys($user->roles);
-  $rids[] = DRUPAL_ANONYMOUS_RID;
+  $rids = array_keys($user->getRoles());
+  $rids[] = AccountInterface::ANONYMOUS_ROLE;
 
-  $query = db_select('block', 'b');
+  $query = \Drupal::database()->select('block', 'b');
   $query->leftJoin('block_role', 'r', 'b.module = r.module AND b.delta = r.delta');
   $query->condition('b.module', 'block');
-  $query->condition(db_or()
+  $or_condition_group = $query->orConditionGroup()
     ->condition('r.rid', $rids, 'IN')
-    ->isNull('r.rid')
-  );
-  $query->fields('b', array('delta'));
+    ->isNull('r.rid');
+  $query->condition($or_condition_group);
+  $query->fields('b', ['delta']);
   $query->distinct();
   $allowed_bids = $query->execute()->fetchCol();
 
@@ -381,6 +402,7 @@ function linkchecker_cron() {
     \Drupal::state()->set('linkchecker.cleanup_links_last', REQUEST_TIME);
   }
 
+  /* httprl module does not exists yet for D8
   // Run link checker in a new process, independent of cron.
   if (\Drupal::moduleHandler()->moduleExists('httprl') && \Drupal::config('linkchecker.settings')->get('check.library') == 'httprl') {
     // Setup callback options array; call _linkchecker_check_links() in the
@@ -393,7 +415,7 @@ function linkchecker_cron() {
 
     // Exit here so we don't call _linkchecker_check_links() in this process.
     return;
-  }
+  }*/
   // Run the link checks the normal way.
   _linkchecker_check_links();
 }
@@ -412,119 +434,132 @@ function _linkchecker_check_links() {
   // Make sure this is the only process trying to run this function.
   $lock = \Drupal::lock();
   if ($lock->acquire(__FUNCTION__, $max_execution_time)) {
-    linkchecker_watchdog_log('linkchecker', 'Attempted to re-run link checks while they are already running.', array(), WATCHDOG_WARNING);
-    return FALSE;
-  }
 
-  $has_httprl = (\Drupal::moduleHandler()->moduleExists('httprl') && $config->get('check.library') == 'httprl');
+    // httprl module does not exists yet for D8
+    // $has_httprl = (\Drupal::moduleHandler()->moduleExists('httprl') && $config->get('check.library') == 'httprl');
+    $has_httprl = FALSE;
 
-  // Do not confuse admins with a setting of maximum checkable links per cron
-  // run and guess that 2 links can be checked per second with 1 thread, what is
-  // nevertheless uncommon. The max_execution_time can be used to calculate
-  // a useful value that is higher, but not totally out of scope and limits the
-  // query result set to a reasonable size.
-  $linkchecker_check_connections_max = $config->get('check.connections_max');
-  $check_links_max_per_cron_run = ($has_httprl) ? ($linkchecker_check_connections_max * $max_execution_time) : $max_execution_time;
+    // Do not confuse admins with a setting of maximum checkable links per cron
+    // run and guess that 2 links can be checked per second with 1 thread, what is
+    // nevertheless uncommon. The max_execution_time can be used to calculate
+    // a useful value that is higher, but not totally out of scope and limits the
+    // query result set to a reasonable size.
+    $linkchecker_check_connections_max = $config->get('check.connections_max');
 
-  $linkchecker_check_links_interval = $config->get('check.interval');
-  $linkchecker_check_useragent = $config->get('check.useragent');
+    $check_links_max_per_cron_run = ($has_httprl) ? ($linkchecker_check_connections_max * $max_execution_time) : $max_execution_time;
 
-  // Connection limit can be overridden via settings.php. Two connections is the
-  // limit defined in RFC http://www.ietf.org/rfc/rfc2616.txt. Modern browsers
-  // are typically using 6-8 connections and no more. Never use more and keep
-  // in mind that you can overload other people servers.
-  $linkchecker_check_domain_connections = $config->get('check.connections_max_per_domain');
+    $linkchecker_check_links_interval = $config->get('check.interval');
+    $linkchecker_check_useragent = $config->get('check.useragent');
 
-  // Get URLs for checking.
-  $links = db_query_range('SELECT * FROM {linkchecker_link} WHERE last_checked < :last_checked AND status = :status ORDER BY last_checked, lid ASC', 0, $check_links_max_per_cron_run, [':last_checked' => REQUEST_TIME - $linkchecker_check_links_interval, ':status' => 1]);
-  $links_remaining = $links->rowCount();
+    // Connection limit can be overridden via settings.php. Two connections is the
+    // limit defined in RFC http://www.ietf.org/rfc/rfc2616.txt. Modern browsers
+    // are typically using 6-8 connections and no more. Never use more and keep
+    // in mind that you can overload other people servers.
+    $linkchecker_check_domain_connections = $config->get('check.connections_max_per_domain');
 
-  foreach ($links as $link) {
-    $headers = [];
-    $headers['User-Agent'] = $linkchecker_check_useragent;
+    // Get URLs for checking.
+    $connection = \Drupal::database();
+    $links = $connection->queryRange('SELECT * FROM {linkchecker_link} WHERE last_checked < :last_checked AND status = :status ORDER BY last_checked, lid ASC', 0, $check_links_max_per_cron_run, [':last_checked' => REQUEST_TIME - $linkchecker_check_links_interval, ':status' => 1]);
+    $links_remaining = Database::RETURN_AFFECTED;
 
-    $uri = @parse_url($link->url);
+    foreach ($links as $link) {
+      $headers = [];
+      $headers['User-Agent'] = $linkchecker_check_useragent;
 
-    // URL contains a fragment.
-    if (in_array($link->method, ['HEAD', 'GET']) && !empty($uri['fragment'])) {
-      // We need the full content and not only the HEAD.
-      $link->method = 'GET';
-      // Request text content only (like Firefox/Chrome).
-      $headers['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
-    }
-    elseif ($link->method == 'GET') {
-      // Range: Only request the first 1024 bytes from remote server. This is
-      // required to prevent timeouts on URLs that are large downloads.
-      $headers['Range'] = 'bytes=0-1024';
-    }
+      $uri = @parse_url($link->url);
 
-    // Add in the headers.
-    $options = [
-      'headers' => $headers,
-      'method' => $link->method,
-      'max_redirects' => 0,
-    ];
+      // URL contains a fragment.
+      if (in_array($link->method, ['HEAD', 'GET']) && !empty($uri['fragment'])) {
+        // We need the full content and not only the HEAD.
+        $link->method = 'GET';
+        // Request text content only (like Firefox/Chrome).
+        $headers['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
+      }
+      elseif ($link->method == 'GET') {
+        // Range: Only request the first 1024 bytes from remote server. This is
+        // required to prevent timeouts on URLs that are large downloads.
+        $headers['Range'] = 'bytes=0-1024';
+      }
 
-    if ($has_httprl) {
-      // Define the callback and add the $link object to it.
-      // Notes:
-      // - 'global_timeout' does not require a timer_read('page'), as this job
-      //   runs in a new process, independent of cron.
-      $options += [
-        'global_connections' => $linkchecker_check_connections_max,
-        'global_timeout' => $max_execution_time - 30,
-        'domain_connections' => $linkchecker_check_domain_connections,
-        'callback' => [
-          [
-            'function' => '_linkchecker_status_handling',
-          ],
-          $link, // This need to be passed or it's not send back to _linkchecker_status_handling()
-        ],
+      // Add in the headers.
+      $options = [
+        'headers' => $headers,
+        'method' => $link->method,
+        'max_redirects' => 0,
       ];
-      // Queue up the requests.
-      httprl_request($link->url, $options);
-      $links_remaining--;
 
-      // After all links are queued, run the url checks.
-      if ($links_remaining == 0) {
-        httprl_send_request();
-      }
-    }
-    else {
-      // Drupal core.
-      try {
-        // @fixme: Object is totally different in D8.
-        $response = \Drupal::httpClient()->request($link->method, $link->url, $options);
-        //$response = drupal_http_request($link->url, $options);
-
-        // @fixme
-        // Add 'redirect_code' property to core response object for consistency
-        // with HTTPRL object.
-        //if ($response->code == 301 && !isset($response->redirect_code)) {
-        //  $response->redirect_code = $response->code;
-        //}
-        // Add 'uri' property to core response object for 'fragment' check and
-        // consistency with HTTPRL object.
-        //$response->uri = $uri;
-
-        _linkchecker_status_handling($response, $link);
-
-        if ((timer_read('page') / 1000) > ($max_execution_time / 2)) {
-          // Stop once we have used over half of the maximum execution time.
-          break;
+      if ($has_httprl) {
+        // Define the callback and add the $link object to it.
+        // Notes:
+        // - 'global_timeout' does not require a timer_read('page'), as this job
+        //   runs in a new process, independent of cron.
+        $options += [
+          'global_connections' => $linkchecker_check_connections_max,
+          'global_timeout' => $max_execution_time - 30,
+          'domain_connections' => $linkchecker_check_domain_connections,
+          'callback' => [
+            [
+              'function' => '_linkchecker_status_handling',
+            ],
+            $link, // This need to be passed or it's not send back to _linkchecker_status_handling()
+          ],
+        ];
+        // Queue up the requests.
+        httprl_request($link->url, $options);
+        $links_remaining--;
+
+        // After all links are queued, run the url checks.
+        if ($links_remaining == 0) {
+          httprl_send_request();
         }
       }
-      catch (RequestException $exception) {
-        watchdog_exception('linkchecker', $exception);
+      else {
+        // Drupal core.
+        try {
+          // @fixme: Object is totally different in D8.
+
+          $response = \Drupal::httpClient()->request($link->method, $link->url, $options);
+
+          // @fixme
+          // Add 'redirect_code' property to core response object for consistency
+          // with HTTPRL object.
+          //if ($response->code == 301 && !isset($response->redirect_code)) {
+          //  $response->redirect_code = $response->code;
+          //}
+          // Add 'uri' property to core response object for 'fragment' check and
+          // consistency with HTTPRL object.
+          //$response->uri = $uri;
+
+          _linkchecker_status_handling($response, $link);
+
+          if ((Timer::read('page') / 1000) > ($max_execution_time / 2)) {
+            // Stop once we have used over half of the maximum execution time.
+            break;
+          }
+        }
+        catch (ClientException $e) {
+          $response = $e->getResponse();
+          _linkchecker_status_handling($response, $link);
+          if ((Timer::read('page') / 1000) > ($max_execution_time / 2)) {
+            // Stop for loop.
+            break;
+          }
+
+        }
       }
     }
-  }
 
-  // Release the lock.
-  $lock->release(__FUNCTION__);
-  linkchecker_watchdog_log('linkchecker', 'Link checks completed.', array(), WATCHDOG_INFO);
-  linkchecker_watchdog_log('linkchecker', 'Memory usage: @memory_get_usage, Peak memory usage: @memory_get_peak_usage.', array('@memory_get_peak_usage' => format_size(memory_get_peak_usage()), '@memory_get_usage' => format_size(memory_get_usage())), WATCHDOG_DEBUG);
-  return TRUE;
+    // Release the lock.
+    $lock->release(__FUNCTION__);
+
+    linkchecker_watchdog_log('linkchecker', 'Memory usage: @memory_get_usage, Peak memory usage: @memory_get_peak_usage.', ['@memory_get_peak_usage' => format_size(memory_get_peak_usage()), '@memory_get_usage' => format_size(memory_get_usage())], RfcLogLevel::DEBUG);
+    return TRUE;
+
+  }
+  else {
+    linkchecker_watchdog_log('linkchecker', 'Attempted to re-run link checks while they are already running.', [], RfcLogLevel::WARNING);
+    return FALSE;
+  }
 }
 
 /**
@@ -538,7 +573,7 @@ function _linkchecker_check_links() {
  */
 function _linkchecker_status_handling(&$response, $link) {
   $config = \Drupal::config('linkchecker.settings');
-  $ignore_response_codes = preg_split('/(\r\n?|\n)/', variable_get('linkchecker_ignore_response_codes', "200\n206\n302\n304\n401\n403"));
+  $ignore_response_codes = preg_split('/(\r\n?|\n)/', \Drupal::config('linkchecker.settings')->get('error.ignore_response_codes'));
 
   // - Prevent E_ALL warnings in DB updates for non-existing $response->error.
   // - @todo drupal_http_request() may not provide an UTF8 encoded error message
@@ -551,8 +586,8 @@ function _linkchecker_status_handling(&$response, $link) {
   if (!isset($response->status_message)) {
     $response->status_message = '';
   }
-  $response->error = trim(drupal_convert_to_utf8($response->error, 'ISO-8859-1'));
-  $response->status_message = trim(drupal_convert_to_utf8($response->status_message, 'ISO-8859-1'));
+  $response->error = trim(Unicode::convertToUtf8($response->error, 'ISO-8859-1'));
+  $response->status_message = trim(Unicode::convertToUtf8($response->status_message, 'ISO-8859-1'));
 
   // Destination anchors in HTML documents may be specified either by:
   // - the A element (naming it with the name attribute)
@@ -563,14 +598,16 @@ function _linkchecker_status_handling(&$response, $link) {
   // - and must not contain '/' or ',' as this are not normal anchors.
   // - and '#top' is a reserved fragment that must not exist in a page.
   // See http://www.w3.org/TR/html401/struct/links.html
+
+  $response->code = $response->getStatusCode();
   if ($response->code == 200
-    && !empty($response->data)
-    && !empty($response->headers['content-type'])
-    && !empty($response->uri['fragment'])
-    && preg_match('/=|\/|,/', $response->uri['fragment']) == FALSE
-    && !in_array($response->uri['fragment'], array('#top'))
-    && in_array($response->headers['content-type'], array('text/html', 'application/xhtml+xml', 'application/xml'))
-    && !preg_match('/(\s[^>]*(name|id)(\s+)?=(\s+)?["\'])(' . preg_quote($response->uri['fragment'], '/') . ')(["\'][^>]*>)/i', $response->data)
+    && !empty($response->getBody())
+    && !empty($response->getHeader('Content-Type'))
+    && !empty($response->getHeader('Link'))
+    && preg_match('/=|\/|,/', $response->getHeader('Link')[1]) == FALSE
+    && !in_array($response->getHeader('Link')[1], ['#top'])
+    && in_array($response->getHeader('Content-Type'), ['text/html', 'application/xhtml+xml', 'application/xml'])
+    && !preg_match('/(\s[^>]*(name|id)(\s+)?=(\s+)?["\'])(' . preg_quote($response->getHeader('Link')[1], '/') . ')(["\'][^>]*>)/i', $response->getBody())
     ) {
     // Override status code 200 with status code 404 so it can be handled with
     // default status code 404 logic and custom error text.
@@ -586,14 +623,14 @@ function _linkchecker_status_handling(&$response, $link) {
     case -2: // HTTPRL: maximum allowed redirects exhausted.
     case 301:
       // Remote site send status code 301 and link needs an update.
-      db_update('linkchecker_link')
+      \Drupal::database()->update('linkchecker_link')
         ->condition('lid', $link->lid)
-        ->fields(array(
+        ->fields([
           'code' => $response->redirect_code,
           'error' => $response->status_message,
           'fail_count' => 0,
           'last_checked' => time(),
-        ))
+        ])
         ->expression('fail_count', 'fail_count + 1')
         ->execute();
 
@@ -601,51 +638,54 @@ function _linkchecker_status_handling(&$response, $link) {
       // a new link. The remote site owner was so kind to provide us the new
       // link and if we trust this change we are able to replace the old link
       // with the new one without any hand work.
-      $auto_repair_301 = variable_get('linkchecker_action_status_code_301', 0);
-      if ($auto_repair_301 && $auto_repair_301 <= ($link->fail_count + 1) && valid_url($response->redirect_url, TRUE)) {
+      $auto_repair_301 = \Drupal::config('linkchecker.settings')->get('error.action_status_code_301');
+      if ($auto_repair_301 && $auto_repair_301 <= ($link->fail_count + 1) && UrlHelper::isValid($response->redirect_url, TRUE)) {
         // Switch anonymous user to an admin.
         $accountSwitcher = Drupal::service('account_switcher');
-        $accountSwitcher->switchTo(new UserSession(array('uid' => user_load_by_name($config->get('error.impersonate_account')))));
+        $accountSwitcher->switchTo(new UserSession(['uid' => user_load_by_name($config->get('error.impersonate_account'))]));
 
         // NODES: Autorepair all nodes having this outdated link.
-        $result = db_query('SELECT nid FROM {linkchecker_node} WHERE lid = :lid', array(':lid' => $link->lid));
+        $connection = \Drupal::database();
+        $result = $connection->query('SELECT nid FROM {linkchecker_node} WHERE lid = :lid', [':lid' => $link->lid]);
+
         foreach ($result as $row) {
-          // Explicitly don't use node_load_multiple() or the module may run
+          // Explicitly don't use Node::load_multiple() or the module may run
           // into issues like http://drupal.org/node/1210606. With this logic
           // nodes can be updated until an out of memory occurs and further
           // updates will be made on the remaining nodes only.
-          $node = node_load($row->nid);
-
+          $node = Node::load($row->nid);
           // Has the node object loaded successfully?
           if (is_object($node)) {
             $node_original = clone $node;
-            $node = _linkchecker_replace_fields('node', $node->type, $node, $link->url, $response->redirect_url);
+            $node = _linkchecker_replace_fields('node', $node->bundle(), $node, $link->url, $response->redirect_url);
 
             if ($node_original != $node) {
               // Always use the default revision setting. For more information,
               // see node_object_prepare().
-              $node_options = variable_get('node_options_' . $node->type, array('status', 'promote'));
+              $node_options = \Drupal::config('linkchecker.settings')->get('node_options_' . $node->bundle());
               $node->revision = in_array('revision', $node_options);
 
               // Generate a log message for the node_revisions table, visible on
               // the node's revisions tab.
-              $node->log = t('Changed permanently moved link in %node from %src to %dst.', array('%node' => url('node/' . $node->nid), '%src' => $link->url, '%dst' => $response->redirect_url));
+              $node->log = t('Changed permanently moved link in %node from %src to %dst.', ['%node' => url('node/' . $node->id()), '%src' => $link->url, '%dst' => $response->redirect_url]);
 
               // Save changed node and update the node link list.
-              node_save($node);
-              linkchecker_watchdog_log('linkchecker', 'Changed permanently moved link in %node from %src to %dst.', array('%node' => url('node/' . $node->nid), '%src' => $link->url, '%dst' => $response->redirect_url), WATCHDOG_INFO);
+              $node->save();
+              linkchecker_watchdog_log('linkchecker', 'Changed permanently moved link in %node from %src to %dst.', ['%node' => url('node/' . $node->id()), '%src' => $link->url, '%dst' => $response->redirect_url], RfcLogLevel::INFO);
             }
             else {
-              linkchecker_watchdog_log('linkchecker', 'Link update in node failed. Permanently moved link %src not found in node %node. Manual fix required.', array('%node' => url('node/' . $row->nid), '%src' => $link->url), WATCHDOG_WARNING);
+              linkchecker_watchdog_log('linkchecker', 'Link update in node failed. Permanently moved link %src not found in node %node. Manual fix required.', ['%node' => url('node/' . $row->nid), '%src' => $link->url], RfcLogLevel::WARNING);
             }
           }
           else {
-            linkchecker_watchdog_log('linkchecker', 'Loading node %node for update failed. Manual fix required.', array('%node' => $row->nid), WATCHDOG_ERROR);
+            linkchecker_watchdog_log('linkchecker', 'Loading node %node for update failed. Manual fix required.', ['%node' => $row->nid], WATCHDOG_ERROR);
           }
         }
 
         // COMMENTS: Autorepair all comments having this outdated link.
-        $result = db_query('SELECT cid FROM {linkchecker_comment} WHERE lid = :lid', array(':lid' => $link->lid));
+        $connection = \Drupal::database();
+        $result = $connection->query('SELECT cid FROM {linkchecker_comment} WHERE lid = :lid', [':lid' => $link->lid]);
+
         foreach ($result as $row) {
           // Explicitly don't use comment_load_multiple() or the module may run
           // into issues like http://drupal.org/node/1210606. With this logic
@@ -666,20 +706,22 @@ function _linkchecker_status_handling(&$response, $link) {
             // Save changed comment and update the comment link list.
             if ($comment_original != $comment) {
               comment_save($comment);
-              linkchecker_watchdog_log('linkchecker', 'Changed permanently moved link in comment %comment from %src to %dst.', array('%comment' => $comment->cid, '%src' => $link->url, '%dst' => $response->redirect_url), WATCHDOG_INFO);
+              linkchecker_watchdog_log('linkchecker', 'Changed permanently moved link in comment %comment from %src to %dst.', ['%comment' => $comment->cid, '%src' => $link->url, '%dst' => $response->redirect_url], RfcLogLevel::INFO);
             }
             else {
-              linkchecker_watchdog_log('linkchecker', 'Link update in comment failed. Permanently moved link %src not found in comment %comment. Manual fix required.', array('%comment' => $comment->cid, '%src' => $link->url), WATCHDOG_WARNING);
+              linkchecker_watchdog_log('linkchecker', 'Link update in comment failed. Permanently moved link %src not found in comment %comment. Manual fix required.', ['%comment' => $comment->cid, '%src' => $link->url], RfcLogLevel::WARNING);
             }
           }
           else {
-            linkchecker_watchdog_log('linkchecker', 'Loading comment %comment for update failed. Manual fix required.', array('%comment' => $comment->cid), WATCHDOG_ERROR);
+            linkchecker_watchdog_log('linkchecker', 'Loading comment %comment for update failed. Manual fix required.', ['%comment' => $comment->cid], WATCHDOG_ERROR);
           }
         }
 
         // CUSTOM BLOCKS: Autorepair all custom blocks having this outdated
         // link.
-        $result = db_query('SELECT bid FROM {linkchecker_block_custom} WHERE lid = :lid', array(':lid' => $link->lid));
+        $connection = \Drupal::database();
+        $result = $connection->query('SELECT bid FROM {linkchecker_block_custom} WHERE lid = :lid', [':lid' => $link->lid]);
+
         foreach ($result as $row) {
           $block_custom = linkchecker_block_custom_block_get($row->bid);
 
@@ -698,14 +740,14 @@ function _linkchecker_status_handling(&$response, $link) {
               // There is no hook that fires on block_custom_block_save(),
               // therefore do link extraction programmatically.
               _linkchecker_add_block_custom_links($block_custom, $block_custom->delta);
-              linkchecker_watchdog_log('linkchecker', 'Changed permanently moved link in custom block %bid from %src to %dst.', array('%bid' => $block_custom->delta, '%src' => $link->url, '%dst' => $response->redirect_url), WATCHDOG_INFO);
+              linkchecker_watchdog_log('linkchecker', 'Changed permanently moved link in custom block %bid from %src to %dst.', ['%bid' => $block_custom->delta, '%src' => $link->url, '%dst' => $response->redirect_url], RfcLogLevel::INFO);
             }
             else {
-              linkchecker_watchdog_log('linkchecker', 'Link update in block failed. Permanently moved link %src not found in block %bid. Manual fix required.', array('%bid' => $block_custom->delta, '%src' => $link->url), WATCHDOG_WARNING);
+              linkchecker_watchdog_log('linkchecker', 'Link update in block failed. Permanently moved link %src not found in block %bid. Manual fix required.', ['%bid' => $block_custom->delta, '%src' => $link->url], RfcLogLevel::WARNING);
             }
           }
           else {
-            linkchecker_watchdog_log('linkchecker', 'Loading block %bid for update failed. Manual fix required.', array('%bid' => $block_custom->delta), WATCHDOG_ERROR);
+            linkchecker_watchdog_log('linkchecker', 'Loading block %bid for update failed. Manual fix required.', ['%bid' => $block_custom->delta], RfcLogLevel::ERROR);
           }
         }
 
@@ -713,29 +755,30 @@ function _linkchecker_status_handling(&$response, $link) {
         $accountSwitcher->switchBack();
       }
       else {
-        linkchecker_watchdog_log('linkchecker', 'Link %link has changed and needs to be updated.', array('%link' => $link->url), WATCHDOG_NOTICE, l(t('Broken links'), 'admin/reports/linkchecker'));
+        linkchecker_watchdog_log('linkchecker', 'Link %link has changed and needs to be updated.', ['%link' => $link->url], RfcLogLevel::NOTICE, l(t('Broken links'), 'admin/reports/linkchecker'));
       }
       break;
 
     case 404:
-      db_update('linkchecker_link')
+      \Drupal::database()->update('linkchecker_link')
         ->condition('lid', $link->lid)
-        ->fields(array(
+        ->fields([
           'code' => $response->code,
           'error' => $response->error,
           'fail_count' => 0,
           'last_checked' => time(),
-        ))
+        ])
         ->expression('fail_count', 'fail_count + 1')
         ->execute();
-      linkchecker_watchdog_log('linkchecker', 'Broken link %link has been found.', array('%link' => $link->url), WATCHDOG_NOTICE, l(t('Broken links'), 'admin/reports/linkchecker'));
+      $linkchecker_report__url = Url::fromRoute('linkchecker.admin_report_page', ['attributes' => ['target' => '_blank']]);
+      linkchecker_watchdog_log('linkchecker', 'Broken link %link has been found.', ['%link' => $link->url], RfcLogLevel::NOTICE, Drupal::l(t('Broken links'), $linkchecker_report__url));
 
       // If unpublishing limit is reached, unpublish all nodes having this link.
-      $linkchecker_action_status_code_404 = variable_get('linkchecker_action_status_code_404', 0);
+      $linkchecker_action_status_code_404 = \Drupal::config('linkchecker.settings')->get('error.action_status_code_404');
       if ($linkchecker_action_status_code_404 && $linkchecker_action_status_code_404 <= ($link->fail_count + 1)) {
         // Switch anonymous user to an admin.
         $accountSwitcher = Drupal::service('account_switcher');
-        $accountSwitcher->switchTo(new UserSession(array('uid' => user_load_by_name($config->get('error.impersonate_account')))));
+        $accountSwitcher->switchTo(new UserSession(['uid' => user_load_by_name($config->get('error.impersonate_account'))]));
         _linkchecker_unpublish_nodes($link->lid);
         $accountSwitcher->switchBack();
       }
@@ -744,81 +787,88 @@ function _linkchecker_status_handling(&$response, $link) {
     case 405:
       // - 405: Special error handling if method is not allowed. Switch link
       //   checking to GET method and try again.
-      db_update('linkchecker_link')
+
+      \Drupal::database()->update('linkchecker_link')
         ->condition('lid', $link->lid)
-        ->fields(array(
+        ->fields([
           'method' => 'GET',
           'code' => $response->code,
           'error' => $response->error,
           'fail_count' => 0,
           'last_checked' => time(),
-        ))
+        ])
         ->expression('fail_count', 'fail_count + 1')
         ->execute();
 
-      linkchecker_watchdog_log('linkchecker', 'Method HEAD is not allowed for link %link. Method has been changed to GET.', array('%link' => $link->url), WATCHDOG_INFO, l(t('Broken links'), 'admin/reports/linkchecker'));
+      $linkchecker_report__url = Url::fromRoute('linkchecker.admin_report_page', ['attributes' => ['target' => '_blank']]);
+      linkchecker_watchdog_log('linkchecker', 'Method HEAD is not allowed for link %link. Method has been changed to GET.', ['%link' => $link->url], RfcLogLevel::NOTICE, Drupal::l(t('Broken links'), $linkchecker_report__url));
+
       break;
 
     case 500:
       // - 500: Like WGET, try with GET on "500 Internal server error".
       // - If GET also fails with status code 500, than the link is broken.
       if ($link->method == 'GET' && $response->code == 500) {
-        db_update('linkchecker_link')
-        ->condition('lid', $link->lid)
-        ->fields(array(
-          'code' => $response->code,
-          'error' => $response->error,
-          'fail_count' => 0,
-          'last_checked' => time(),
-        ))
-        ->expression('fail_count', 'fail_count + 1')
-        ->execute();
+        \Drupal::database()->update('linkchecker_link')
+          ->condition('lid', $link->lid)
+          ->fields([
+            'code' => $response->code,
+            'error' => $response->error,
+            'fail_count' => 0,
+            'last_checked' => time(),
+          ])
+          ->expression('fail_count', 'fail_count + 1')
+          ->execute();
+
+        $linkchecker_report__url = Url::fromRoute('linkchecker.admin_report_page', ['attributes' => ['target' => '_blank']]);
+        linkchecker_watchdog_log('linkchecker', 'Broken link %link has been found.', ['%link' => $link->url], RfcLogLevel::NOTICE, Drupal::l(t('Broken links'), $linkchecker_report__url));
 
-        linkchecker_watchdog_log('linkchecker', 'Broken link %link has been found.', array('%link' => $link->url), WATCHDOG_NOTICE, l(t('Broken links'), 'admin/reports/linkchecker'));
       }
       else {
-        db_update('linkchecker_link')
-        ->condition('lid', $link->lid)
-        ->fields(array(
-          'method' => 'GET',
-          'code' => $response->code,
-          'error' => $response->error,
-          'fail_count' => 0,
-          'last_checked' => time(),
-        ))
-        ->expression('fail_count', 'fail_count + 1')
-        ->execute();
+        \Drupal::database()->update('linkchecker_link')
+          ->condition('lid', $link->lid)
+          ->fields([
+            'method' => 'GET',
+            'code' => $response->code,
+            'error' => $response->error,
+            'fail_count' => 0,
+            'last_checked' => time(),
+          ])
+          ->expression('fail_count', 'fail_count + 1')
+          ->execute();
+
+        $linkchecker_report__url = Url::fromRoute('linkchecker.admin_report_page', ['attributes' => ['target' => '_blank']]);
+        linkchecker_watchdog_log('linkchecker', 'Internal server error for link %link. Method has been changed to GET.', ['%link' => $link->url], RfcLogLevel::NOTICE, Drupal::l(t('Broken links'), $linkchecker_report__url));
 
-        linkchecker_watchdog_log('linkchecker', 'Internal server error for link %link. Method has been changed to GET.', array('%link' => $link->url), WATCHDOG_INFO, l(t('Broken links'), 'admin/reports/linkchecker'));
       }
       break;
 
     default:
       // Don't treat ignored response codes as errors.
       if (in_array($response->code, $ignore_response_codes)) {
-        db_update('linkchecker_link')
+        \Drupal::database()->update('linkchecker_link')
           ->condition('lid', $link->lid)
-          ->fields(array(
+          ->fields([
             'code' => $response->code,
             'error' => $response->error,
             'fail_count' => 0,
             'last_checked' => time(),
-          ))
+          ])
           ->execute();
-        // linkchecker_watchdog_log('linkchecker', 'Unhandled link error %link has been found.', array('%link' => $link->url), WATCHDOG_ERROR, l(t('Broken links'), 'admin/reports/linkchecker'));
+        // linkchecker_watchdog_log('linkchecker', 'Unhandled link error %link has been found.', array('%link' => $link->url), RfcLogLevel::ERROR, l(t('Broken links'), 'admin/reports/linkchecker'));
       }
       else {
-        db_update('linkchecker_link')
+        \Drupal::database()->update('linkchecker_link')
           ->condition('lid', $link->lid)
-          ->fields(array(
+          ->fields([
             'code' => $response->code,
             'error' => $response->error,
             'fail_count' => 0,
             'last_checked' => time(),
-          ))
+          ])
           ->expression('fail_count', 'fail_count + 1')
           ->execute();
-        // linkchecker_watchdog_log('linkchecker', 'Unhandled link error %link has been found.', array('%link' => $link->url), WATCHDOG_ERROR, l(t('Broken links'), 'admin/reports/linkchecker'));
+        // linkchecker_watchdog_log('linkchecker', 'Unhandled link error %link has been found.', array('%link' => $link->url), RfcLogLevel::ERROR, l(t('Broken links'), 'admin/reports/linkchecker'));
       }
   }
 
@@ -830,23 +880,28 @@ function _linkchecker_status_handling(&$response, $link) {
  * @fixme: remove after migration
  * Implements hook_node_type_delete().
  */
+
 function linkchecker_node_type_delete($info) {
-  variable_del('linkchecker_scan_node_' . $info->type);
-  variable_del('linkchecker_scan_comment_' . $info->type);
+  // @todo: Refactor this under D8.
+  //variable_del('linkchecker_scan_node_' . $info->type);
+  //variable_del('linkchecker_scan_comment_' . $info->type);
+  //Drupal::configFactory()->getEditable('linkchecker_scan_node_' . $info->type)->delete();
+  //Drupal::configFactory()->getEditable('linkchecker_scan_comment_' . $info->type)->delete();
 }
 
 /**
  * Implements hook_node_prepare().
  */
-function linkchecker_node_prepare($node) {
+function linkchecker_node_prepare_form(NodeInterface $node, $operation, FormStateInterface $form_state) {
   // Node edit tab is viewed.
-  if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == 'edit' && isset($node->nid)) {
+  if (!$node->isNew()) {
     // Show a message on node edit page if a link check failed once or more.
-    $ignore_response_codes = preg_split('/(\r\n?|\n)/', variable_get('linkchecker_ignore_response_codes', "200\n206\n302\n304\n401\n403"));
-    $links = db_query('SELECT ll.* FROM {linkchecker_node} ln INNER JOIN {linkchecker_link} ll ON ln.lid = ll.lid WHERE ln.nid = :nid AND ll.fail_count > :fail_count AND ll.status = :status AND ll.code NOT IN (:codes)', array(':nid' => $node->nid, ':fail_count' => 0, ':status' => 1, ':codes' => $ignore_response_codes));
+    $ignore_response_codes = preg_split('/(\r\n?|\n)/', \Drupal::config('linkchecker.settings')->get('error.ignore_response_codes'));
+    $connection = \Drupal::database();
+    $links = $connection->query('SELECT ll.* FROM {linkchecker_node} ln INNER JOIN {linkchecker_link} ll ON ln.lid = ll.lid WHERE ln.nid = :nid AND ll.fail_count > :fail_count AND ll.status = :status AND ll.code NOT IN (:codes[])', [':nid' => $node->id(), ':fail_count' => 0, ':status' => 1, ':codes[]' => $ignore_response_codes]);
     foreach ($links as $link) {
       if (_linkchecker_link_access($link)) {
-        drupal_set_message(format_plural($link->fail_count, 'Link check of <a href="@url">@url</a> failed once (status code: @code).', 'Link check of <a href="@url">@url</a> failed @count times (status code: @code).', array('@url' => $link->url, '@code' => $link->code)), 'warning', FALSE);
+        drupal_set_message(format_plural($link->fail_count, 'Link check of <a href="@url">@url</a> failed once (status code: @code).', 'Link check of <a href="@url">@url</a> failed @count times (status code: @code).', ['@url' => $link->url, '@code' => $link->code]), 'warning', FALSE);
       }
     }
   }
@@ -856,7 +911,7 @@ function linkchecker_node_prepare($node) {
  * Implements hook_node_delete().
  */
 function linkchecker_node_delete($node) {
-  _linkchecker_delete_node_links($node->nid);
+  _linkchecker_delete_node_links($node->id());
 }
 
 /**
@@ -866,14 +921,24 @@ function linkchecker_node_insert($node) {
   // Every moderation module saving a forward revision needs to exit here.
   // Please see _linkchecker_isdefaultrevision() for more details.
   // @todo: Refactor this workaround under D8.
-  if (!_linkchecker_isdefaultrevision($node)) {
+
+  if (!$node->isDefaultRevision()) {
     return;
   }
+  // @fixme
+  //if (!_linkchecker_isdefaultrevision($node)) {
+  //   return;
+  // }
 
+  $node_type = NodeType::load($node->bundle());
   // The node is going to be published.
-  if (variable_get('linkchecker_scan_node_' . $node->type, FALSE) && $node->status == NODE_PUBLISHED) {
+
+  if ($node_type->getThirdPartySetting('linkchecker', 'scan_node', FALSE) && $node->isPublished()) {
+
     _linkchecker_add_node_links($node);
+
   }
+
 }
 
 /**
@@ -883,12 +948,16 @@ function linkchecker_node_update($node) {
   // Every moderation module saving a forward revision needs to exit here.
   // Please see _linkchecker_isdefaultrevision() for more details.
   // @todo: Refactor this workaround under D8.
-  if (!_linkchecker_isdefaultrevision($node)) {
+  //if (!_linkchecker_isdefaultrevision($node)) {
+  //  return;
+  //}
+  if (!$node->isDefaultRevision()) {
     return;
   }
 
   // The node is going to be published.
-  if (variable_get('linkchecker_scan_node_' . $node->type, FALSE) && $node->status == NODE_PUBLISHED) {
+  $node_type = NodeType::load($node->bundle());
+  if ($node_type->getThirdPartySetting('linkchecker', 'scan_node', FALSE) && $node->isPublished()) {
     _linkchecker_add_node_links($node);
   }
   else {
@@ -909,8 +978,9 @@ function linkchecker_comment_delete($comment) {
  */
 function linkchecker_comment_insert($comment) {
   // The comment is going to be published.
-  $node_type = db_query('SELECT type FROM {node} WHERE nid = :nid', array(':nid' => $comment->nid))->fetchField();
-  if (variable_get('linkchecker_scan_comment_' . $node_type, FALSE) && $comment->status == COMMENT_PUBLISHED) {
+  $connection = \Drupal::database();
+  $node_type = $connection->query('SELECT type FROM {node} WHERE nid = :nid', [':nid' => $comment->getCommentedEntityId()])->fetchField();
+  if (\Drupal::config('linkchecker.settings')->get('linkchecker_scan_comment_' . $node_type) && $comment->status == COMMENT_PUBLISHED) {
     _linkchecker_add_comment_links($comment);
   }
 }
@@ -920,8 +990,10 @@ function linkchecker_comment_insert($comment) {
  */
 function linkchecker_comment_update($comment) {
   // The node is going to be published.
-  $node_type = db_query('SELECT type FROM {node} WHERE nid = :nid', array(':nid' => $comment->nid))->fetchField();
-  if (variable_get('linkchecker_scan_comment_' . $node_type, FALSE) && $comment->status == COMMENT_PUBLISHED) {
+  $connection = \Drupal::database();
+  $node_type = $connection->query('SELECT type FROM {node} WHERE nid = :nid', [':nid' => $comment->getCommentedEntityId()])->fetchField();
+
+  if (\Drupal::config('linkchecker.settings')->get('linkchecker_scan_comment_' . $node_type) && $comment->status == COMMENT_PUBLISHED) {
     _linkchecker_add_comment_links($comment);
   }
   else {
@@ -947,10 +1019,11 @@ function linkchecker_form_alter(&$form, FormStateInterface $form_state, $form_id
         // Show a message on custom block edit page if a link check failed once
         // or more often.
         $ignore_response_codes = preg_split('/(\r\n?|\n)/', \Drupal::config('linkchecker.settings')->get('error.ignore_response_codes'));
-        $links = db_query('SELECT ll.* FROM {linkchecker_block_custom} lb INNER JOIN {linkchecker_link} ll ON lb.lid = ll.lid WHERE lb.bid = :bid AND ll.fail_count > :fail_count AND ll.status = :status AND ll.code NOT IN (:codes)', array(':bid' => arg(5), ':fail_count' => 0, ':status' => 1, ':codes' => $ignore_response_codes));
+        $connection = \Drupal::database();
+        $links = $connection->query('SELECT ll.* FROM {linkchecker_block_custom} lb INNER JOIN {linkchecker_link} ll ON lb.lid = ll.lid WHERE lb.bid = :bid AND ll.fail_count > :fail_count AND ll.status = :status AND ll.code NOT IN (:codes[])', [':bid' => arg(5), ':fail_count' => 0, ':status' => 1, ':codes[]' => $ignore_response_codes]);
         foreach ($links as $link) {
           if (_linkchecker_link_access($link)) {
-            drupal_set_message(format_plural($link->fail_count, 'Link check of <a href=":url">:url</a> failed once (status code: @code).', 'Link check of <a href=":url">:url</a> failed @count times (status code: @code).', array(':url' => $link->url, '@code' => $link->code)), 'warning', FALSE);
+            drupal_set_message(format_plural($link->fail_count, 'Link check of <a href=":url">:url</a> failed once (status code: @code).', 'Link check of <a href=":url">:url</a> failed @count times (status code: @code).', [':url' => $link->url, '@code' => $link->code]), 'warning', FALSE);
           }
         }
       }
@@ -1014,7 +1087,7 @@ function linkchecker_form_node_type_form_submit(&$form, FormStateInterface $form
   if (!$form['linkchecker']['linkchecker_scan_node']['#default_value'] && $form_state->getValue('linkchecker_scan_node')) {
     // We need to scan this node-type now.
     module_load_include('inc', 'linkchecker', 'linkchecker.batch');
-    batch_set(_linkchecker_batch_import_nodes(array($node_type)));
+    batch_set(_linkchecker_batch_import_nodes([$node_type]));
   }
 
   // Default to TRUE if comment module isn't enabled, we don't care.
@@ -1027,7 +1100,7 @@ function linkchecker_form_node_type_form_submit(&$form, FormStateInterface $form
   if (!$original_linkchecker_comment_state && !empty($form_state->getValue('linkchecker_scan_comment'))) {
     // We need to scan comments for this node-type now.
     module_load_include('inc', 'linkchecker', 'linkchecker.batch');
-    batch_set(_linkchecker_batch_import_comments(array($node_type)));
+    batch_set(_linkchecker_batch_import_comments([$node_type]));
   }
 }
 
@@ -1050,11 +1123,13 @@ function linkchecker_form_comment_form_alter(&$form, &$form_state, $form_id) {
   if ((empty($form_state['input']) || (isset($form_state['input']['op']) && $form_state['input']['op'] == t('Preview'))) && arg(0) == 'comment' && is_numeric(arg(1)) && arg(2) == 'edit') {
     // Show a message on comment edit page if a link check failed once or
     // more often.
-    $ignore_response_codes = preg_split('/(\r\n?|\n)/', variable_get('linkchecker_ignore_response_codes', "200\n206\n302\n304\n401\n403"));
-    $links = db_query('SELECT ll.* FROM {linkchecker_comment} lc INNER JOIN {linkchecker_link} ll ON lc.lid = ll.lid WHERE lc.cid = :cid AND ll.fail_count > :fail_count AND ll.status = :status AND ll.code NOT IN (:codes)', array(':cid' => arg(1), ':fail_count' => 0, ':status' => 1, ':codes' => $ignore_response_codes));
+    $ignore_response_codes = preg_split('/(\r\n?|\n)/', \Drupal::config('linkchecker.settings')->get('error.ignore_response_codes'));
+
+    $connection = \Drupal::database();
+    $links = $connection->query('SELECT ll.* FROM {linkchecker_comment} lc INNER JOIN {linkchecker_link} ll ON lc.lid = ll.lid WHERE lc.cid = :cid AND ll.fail_count > :fail_count AND ll.status = :status AND ll.code NOT IN (:codes[])', [':cid' => arg(1), ':fail_count' => 0, ':status' => 1, ':codes[]' => $ignore_response_codes]);
     foreach ($links as $link) {
       if (_linkchecker_link_access($link)) {
-        drupal_set_message(format_plural($link->fail_count, 'Link check of <a href="@url">@url</a> failed once (status code: @code).', 'Link check of <a href="@url">@url</a> failed @count times (status code: @code).', array('@url' => $link->url, '@code' => $link->code)), 'warning', FALSE);
+        drupal_set_message(format_plural($link->fail_count, 'Link check of <a href="@url">@url</a> failed once (status code: @code).', 'Link check of <a href="@url">@url</a> failed @count times (status code: @code).', ['@url' => $link->url, '@code' => $link->code]), 'warning', FALSE);
       }
     }
   }
@@ -1064,8 +1139,10 @@ function linkchecker_form_comment_form_alter(&$form, &$form_state, $form_id) {
  * Custom submit handler for block add page.
  */
 function linkchecker_block_custom_add_form_submit($form, &$form_state) {
-  if (variable_get('linkchecker_scan_blocks', 0)) {
-    $bid = db_query('SELECT MAX(bid) FROM {block_custom}')->fetchField();
+  if (\Drupal::config('linkchecker.settings')->get('scan_blocks')) {
+    $connection = \Drupal::database();
+    $bid = $connection->query('SELECT MAX(bid) FROM {block_custom}')->fetchField();
+
     _linkchecker_add_block_custom_links($form_state['values'], $bid);
   }
 }
@@ -1074,7 +1151,7 @@ function linkchecker_block_custom_add_form_submit($form, &$form_state) {
  * Custom submit handler for block configure page.
  */
 function linkchecker_block_custom_configure_form_submit($form, &$form_state) {
-  if (variable_get('linkchecker_scan_blocks', 0)) {
+  if (\Drupal::config('linkchecker.settings')->get('scan_blocks')) {
     _linkchecker_add_block_custom_links($form_state['values'], $form_state['values']['delta']);
   }
 }
@@ -1109,7 +1186,7 @@ function linkchecker_block_custom_block_get($bid) {
     $block->module = 'block';
     $block->delta = $block_custom['bid'];
     $block->info = $block_custom['info'];
-    $block->body = array();
+    $block->body = [];
     $block->body['value'] = $block_custom['body'];
     $block->body['format'] = $block_custom['format'];
   }
@@ -1136,26 +1213,21 @@ function linkchecker_block_custom_block_get($bid) {
  *   structured array (see above) if $return_field_names is TRUE.
  */
 function _linkchecker_extract_node_links($node, $return_field_names = FALSE) {
-
   $filter = new stdClass();
   $filter->settings['filter_url_length'] = 72;
 
   // Create array of node fields to scan.
-  $text_items = array();
-  $text_items_by_field = array();
+  $text_items = [];
+  $text_items_by_field = [];
 
   // Add fields typically not used for urls to the bottom. This way a link may
   // found earlier while looping over $text_items_by_field below.
-  $text_items_by_field = array_merge($text_items_by_field, _linkchecker_parse_fields('node', $node->type, $node, TRUE));
-  $text_items_by_field['title'][] = _filter_url($node->title, $filter);
+  $link_check = _linkchecker_parse_fields('node', $node->bundle(), $node, TRUE);
+
+  $text_items_by_field = array_merge($text_items_by_field, $link_check);
   $text_items = _linkchecker_array_values_recursive($text_items_by_field);
 
-  // Get the absolute node path for extraction of relative links.
-  $languages = language_list();
-  // Note: An "undefined language" (value: 'und') isn't listed in the available
-  // languages variable $languages.
-  $url_options = (empty($node->language) || empty($languages[$node->language])) ? array('absolute' => TRUE) : array('language' => $languages[$node->language], 'absolute' => TRUE);
-  $path = url('node/' . $node->nid, $url_options);
+  $path = Url::fromUri('base:' . 'node/' . $node->id())->toString();
 
   // Extract all links in a node.
   $links = _linkchecker_extract_links(implode(' ', $text_items), $path);
@@ -1166,7 +1238,7 @@ function _linkchecker_extract_node_links($node, $return_field_names = FALSE) {
     return $links;
   }
   else {
-    $field_names = array();
+    $field_names = [];
     foreach ($text_items_by_field as $field_name => $items) {
       foreach ($items as $item) {
         foreach ($links as $uri => $link) {
@@ -1189,9 +1261,9 @@ function _linkchecker_extract_node_links($node, $return_field_names = FALSE) {
         }
       }
     }
-
     return $field_names;
   }
+
 }
 
 /**
@@ -1204,32 +1276,49 @@ function _linkchecker_extract_node_links($node, $return_field_names = FALSE) {
  *   the need for content re-scans is detected by the number of missing links.
  */
 function _linkchecker_add_node_links($node, $skip_missing_links_detection = FALSE) {
+
   $links = array_keys(_linkchecker_extract_node_links($node));
 
   // Node have links.
   if (!empty($links)) {
     // Remove all links from the links array already in the database and only
     // add missing links to database.
-    $missing_links = _linkchecker_node_links_missing($node->nid, $links);
+    $missing_links = _linkchecker_node_links_missing($node->id(), $links);
 
     // Only add links to database that do not exists.
     $i = 0;
     foreach ($missing_links as $url) {
-      $urlhash = drupal_hash_base64($url);
-      $link = db_query('SELECT lid FROM {linkchecker_link} WHERE urlhash = :urlhash', array(':urlhash' => $urlhash))->fetchObject();
+      $urlhash = Crypt::hashBase64($url);
+      $connection = \Drupal::database();
+      $link = $connection->query('SELECT lid FROM {linkchecker_link} WHERE urlhash = :urlhash', [':urlhash' => $urlhash])->fetchObject();
       if (!$link) {
-        $link = new stdClass();
-        $link->urlhash = $urlhash;
-        $link->url = $url;
-        $link->status = _linkchecker_link_check_status_filter($url);
-        drupal_write_record('linkchecker_link', $link);
+        $link = [];
+        $link['urlhash'] = $urlhash;
+        $link['url'] = $url;
+        $link['status'] = _linkchecker_link_check_status_filter($url);
+
+        $lid = \Drupal::database()->insert('linkchecker_link')
+          ->fields($link)
+          ->execute();
+
+        \Drupal::database()->insert('linkchecker_node')
+          ->fields([
+            'nid' => $node->id(),
+            'lid' => $lid,
+          ])
+          ->execute();
+      }
+      else {
+        $result = \Drupal::database()->query("SELECT * FROM {linkchecker_node} WHERE nid = :nid AND lid = :lid", [':nid' => $node->id(), ':lid' => $link->lid])->fetchAll();
+        if (!$result) {
+          \Drupal::database()->insert('linkchecker_node')
+            ->fields([
+              'nid' => $node->id(),
+              'lid' => $link->lid,
+            ])
+            ->execute();
+        }
       }
-      db_insert('linkchecker_node')
-        ->fields(array(
-          'nid' => $node->nid,
-          'lid' => $link->lid,
-        ))
-        ->execute();
 
       // Break processing if max links limit per run has been reached.
       $i++;
@@ -1254,20 +1343,20 @@ function _linkchecker_add_node_links($node, $skip_missing_links_detection = FALS
     $missing_links_count = count($missing_links) - LINKCHECKER_SCAN_MAX_LINKS_PER_RUN;
     if (!$skip_missing_links_detection && $missing_links_count > 0) {
       module_load_include('inc', 'linkchecker', 'linkchecker.batch');
-      batch_set(_linkchecker_batch_import_single_node($node->nid, $missing_links_count));
+      batch_set(_linkchecker_batch_import_single_node($node->id(), $missing_links_count));
 
       // If batches were set in the submit handlers, we process them now,
       // possibly ending execution. We make sure we do not react to the batch
       // that is already being processed (if a batch operation performs a
       // drupal_execute).
       if ($batch = &batch_get() && !isset($batch['current_set'])) {
-        batch_process('node/' . $node->nid);
+        batch_process('node/' . $node->id());
       }
     }
   }
 
   // Remove dead link references for cleanup reasons as very last step.
-  _linkchecker_cleanup_node_references($node->nid, $links);
+  _linkchecker_cleanup_node_references($node->id(), $links);
 }
 
 /**
@@ -1285,15 +1374,15 @@ function _linkchecker_add_comment_links($comment, $skip_missing_links_detection
   $filter->settings['filter_url_length'] = 72;
 
   // Create array of comment fields to scan.
-  $text_items = array();
+  $text_items = [];
   $text_items[] = _filter_url($comment->subject, $filter);
   $text_items = array_merge($text_items, _linkchecker_parse_fields('comment', $comment->node_type, $comment));
 
   // Get the absolute node path for extraction of relative links.
-  $languages = language_list();
-  $node = node_load($comment->nid);
-  $url_options = (empty($node->language) || empty($languages[$node->language])) ? array('absolute' => TRUE) : array('language' => $languages[$node->language], 'absolute' => TRUE);
-  $path = url('node/' . $comment->nid, $url_options);
+  $languages = \Drupal::languageManager()->getLanguages();
+  $node = Node::load($comment->getCommentedEntityId());
+  $url_options = (empty($node->language()->getId()) || empty($languages[$node->language()->getId()])) ? array('absolute' => TRUE) : array('language' => $languages[$node->language()->getId()], 'absolute' => TRUE);
+  $path = url('node/' . $comment->getCommentedEntityId(), $url_options);
 
   // Extract all links in a comment.
   $links = array_keys(_linkchecker_extract_links(implode(' ', $text_items), $path));
@@ -1307,20 +1396,24 @@ function _linkchecker_add_comment_links($comment, $skip_missing_links_detection
     // Only add unique links to database that do not exist.
     $i = 0;
     foreach ($missing_links as $url) {
-      $urlhash = drupal_hash_base64($url);
-      $link = db_query('SELECT lid FROM {linkchecker_link} WHERE urlhash = :urlhash', array(':urlhash' => $urlhash))->fetchObject();
+      $urlhash = Crypt::hashBase64($url);
+
+      $connection = \Drupal::database();
+      $link = $connection->query('SELECT lid FROM {linkchecker_link} WHERE urlhash = :urlhash', [':urlhash' => $urlhash])->fetchObject();
       if (!$link) {
-        $link = new stdClass();
-        $link->urlhash = $urlhash;
-        $link->url = $url;
-        $link->status = _linkchecker_link_check_status_filter($url);
-        drupal_write_record('linkchecker_link', $link);
+        $link = [];
+        $link['urlhash'] = $urlhash;
+        $link['url'] = $url;
+        $link['status'] = _linkchecker_link_check_status_filter($url);
+        $lid = \Drupal::database()->insert('linkchecker_link')
+          ->fields($link)
+          ->execute();
       }
-      db_insert('linkchecker_comment')
-        ->fields(array(
+      \Drupal::database()->insert('linkchecker_comment')
+        ->fields([
           'cid' => $comment->cid,
-          'lid' => $link->lid,
-        ))
+          'lid' => $lid ? $lid : $link->lid,
+        ])
         ->execute();
 
       // Break processing if max links limit per run has been reached.
@@ -1353,7 +1446,7 @@ function _linkchecker_add_comment_links($comment, $skip_missing_links_detection
       // that is already being processed (if a batch operation performs a
       // drupal_execute).
       if ($batch = &batch_get() && !isset($batch['current_set'])) {
-        batch_process('node/' . $comment->nid);
+        batch_process('node/' . $comment->getCommentedEntityId());
       }
     }
   }
@@ -1390,7 +1483,7 @@ function _linkchecker_add_block_custom_links($block_custom, $bid, $skip_missing_
   $filter->settings['filter_url_length'] = 72;
 
   // Create array of custom block fields to scan. All fields cannot exists.
-  $text_items = array();
+  $text_items = [];
   if (!empty($block_custom->info)) {
     $text_items[] = _filter_url($block_custom->info, $filter);
   }
@@ -1411,21 +1504,23 @@ function _linkchecker_add_block_custom_links($block_custom, $bid, $skip_missing_
     // Only add unique links to database that do not exist.
     $i = 0;
     foreach ($missing_links as $url) {
-      $urlhash = drupal_hash_base64($url);
-      $link = db_query('SELECT lid FROM {linkchecker_link} WHERE urlhash = :urlhash', array(':urlhash' => $urlhash))->fetchObject();
+      $urlhash = Crypt::hashBase64($url);
+
+      $connection = \Drupal::database();
+      $link = $connection->query('SELECT lid FROM {linkchecker_link} WHERE urlhash = :urlhash', [':urlhash' => $urlhash])->fetchObject();
       if (!$link) {
-        $link = new stdClass();
-        $link->urlhash = $urlhash;
-        $link->url = $url;
-        $link->status = _linkchecker_link_check_status_filter($url);
-        drupal_write_record('linkchecker_link', $link);
+        $link = [];
+        $link['urlhash'] = $urlhash;
+        $link['url'] = $url;
+        $link['status'] = _linkchecker_link_check_status_filter($url);
+        $lid = \Drupal::database()->insert('linkchecker_block_custom')
+          ->fields($link)
+          ->execute();
       }
-      db_insert('linkchecker_block_custom')
-        ->fields(array(
-          'bid' => $bid,
-          'lid' => $link->lid,
-        ))
-        ->execute();
+      \Drupal::database()->insert('linkchecker_block_custom')->fields([
+        'bid' => $bid,
+        'lid' => $lid ? $lid : $link->lid,
+      ])->execute();
 
       // Break processing if max links limit per run has been reached.
       $i++;
@@ -1473,7 +1568,7 @@ function _linkchecker_add_block_custom_links($block_custom, $bid, $skip_missing_
  *   The node ID.
  */
 function _linkchecker_delete_node_links($nid) {
-  db_delete('linkchecker_node')
+  \Drupal::database()->delete('linkchecker_node')
     ->condition('nid', $nid)
     ->execute();
 }
@@ -1485,7 +1580,7 @@ function _linkchecker_delete_node_links($nid) {
  *   The comment ID.
  */
 function _linkchecker_delete_comment_links($cid) {
-  db_delete('linkchecker_comment')
+  \Drupal::database()->delete('linkchecker_comment')
     ->condition('cid', $cid)
     ->execute();
 }
@@ -1495,10 +1590,9 @@ function _linkchecker_delete_comment_links($cid) {
  *
  * @param int $bid
  *   The block ID.
- *
  */
 function _linkchecker_delete_block_custom_links($bid) {
-  db_delete('linkchecker_block_custom')
+  \Drupal::database()->delete('linkchecker_block_custom')
     ->condition('bid', $bid)
     ->execute();
 }
@@ -1509,11 +1603,12 @@ function _linkchecker_delete_block_custom_links($bid) {
  * @param int $nid
  *   The node ID.
  * @param array $links
+ *   The links.
  */
-function _linkchecker_cleanup_node_references($nid = 0, $links = array()) {
+function _linkchecker_cleanup_node_references($nid = 0, $links = []) {
   if (empty($links)) {
     // Node do not have links. Delete all references if exists.
-    db_delete('linkchecker_node')
+    \Drupal::database()->delete('linkchecker_node')
       ->condition('nid', $nid)
       ->execute();
   }
@@ -1521,11 +1616,11 @@ function _linkchecker_cleanup_node_references($nid = 0, $links = array()) {
     // The node still have more than one link, but other links may have been
     // removed and links no longer in the content need to be deleted from the
     // linkchecker_node reference table.
-    $subquery = db_select('linkchecker_link')
-      ->fields('linkchecker_link', array('lid'))
-      ->condition('urlhash', array_map('drupal_hash_base64', $links), 'IN');
+    $subquery = \Drupal::database()->select('linkchecker_link')
+      ->fields('linkchecker_link', ['lid'])
+      ->condition('urlhash', array_map('\Drupal\Component\Utility\Crypt::hashBase64', $links), 'IN');
 
-    db_delete('linkchecker_node')
+    \Drupal::database()->delete('linkchecker_node')
       ->condition('nid', $nid)
       ->condition('lid', $subquery, 'NOT IN')
       ->execute();
@@ -1539,10 +1634,10 @@ function _linkchecker_cleanup_node_references($nid = 0, $links = array()) {
  *   The comment ID.
  * @param array $links
  */
-function _linkchecker_cleanup_comment_references($cid = 0, $links = array()) {
+function _linkchecker_cleanup_comment_references($cid = 0, $links = []) {
   if (empty($links)) {
     // Comment do not have links. Delete all references if exists.
-    db_delete('linkchecker_comment')
+    \Drupal::database()->delete('linkchecker_comment')
       ->condition('cid', $cid)
       ->execute();
   }
@@ -1550,11 +1645,11 @@ function _linkchecker_cleanup_comment_references($cid = 0, $links = array()) {
     // The comment still have more than one link, but other links may have been
     // removed and links no longer in the content need to be deleted from the
     // linkchecker_comment reference table.
-    $subquery = db_select('linkchecker_link', 'll')
-      ->fields('ll', array('lid'))
-      ->condition('ll.urlhash', array_map('drupal_hash_base64', $links), 'IN');
+    $subquery = \Drupal::database()->select('linkchecker_link', 'll')
+      ->fields('ll', ['lid'])
+      ->condition('ll.urlhash', array_map('\Drupal\Component\Utility\Crypt::hashBase64', $links), 'IN');
 
-    db_delete('linkchecker_comment')
+    \Drupal::database()->delete('linkchecker_comment')
       ->condition('cid', $cid)
       ->condition('lid', $subquery, 'NOT IN')
       ->execute();
@@ -1568,10 +1663,10 @@ function _linkchecker_cleanup_comment_references($cid = 0, $links = array()) {
  *   The block ID.
  * @param array $links
  */
-function _linkchecker_cleanup_block_custom_references($bid = 0, $links = array()) {
+function _linkchecker_cleanup_block_custom_references($bid = 0, $links = []) {
   if (empty($links)) {
     // Block do not have links. Delete all references if exists.
-    db_delete('linkchecker_block_custom')
+    \Drupal::database()->delete('linkchecker_block_custom')
       ->condition('bid', $bid)
       ->execute();
   }
@@ -1579,11 +1674,12 @@ function _linkchecker_cleanup_block_custom_references($bid = 0, $links = array()
     // The block still have more than one link, but other links may have been
     // removed and links no longer in the content need to be deleted from the
     // linkchecker_block_custom reference table.
-    $subquery = db_select('linkchecker_link')
-      ->fields('linkchecker_link', array('lid'))
-      ->condition('urlhash', array_map('drupal_hash_base64', $links), 'IN');
 
-    db_delete('linkchecker_block_custom')
+    $subquery = \Drupal::database()->select('linkchecker_link')
+      ->fields('linkchecker_link', ['lid'])
+      ->condition('urlhash', array_map('\Drupal\Component\Utility\Crypt::hashBase64', $links), 'IN');
+
+    \Drupal::database()->delete('linkchecker_block_custom')
       ->condition('bid', $bid)
       ->condition('lid', $subquery, 'NOT IN')
       ->execute();
@@ -1602,8 +1698,10 @@ function _linkchecker_cleanup_block_custom_references($bid = 0, $links = array()
  *   An array of node references missing in the linkchecker_node table.
  */
 function _linkchecker_node_links_missing($nid, $links) {
-  $result = db_query('SELECT ll.url FROM {linkchecker_link} ll INNER JOIN {linkchecker_node} ln ON ln.lid = ll.lid WHERE ln.nid = :nid AND ll.urlhash IN (:urlhashes)', array(':nid' => $nid, ':urlhashes' => array_map('drupal_hash_base64', $links)));
-  $links_in_database = array();
+
+  $connection = \Drupal::database();
+  $result = $connection->query('SELECT ll.url FROM {linkchecker_link} ll INNER JOIN {linkchecker_node} ln ON ln.lid = ll.lid WHERE ln.nid = :nid AND ll.urlhash IN (:urlhashes[])', [':nid' => $nid, ':urlhashes[]' => array_map('\Drupal\Component\Utility\Crypt::hashBase64', $links)]);
+  $links_in_database = [];
   foreach ($result as $row) {
     $links_in_database[] = $row->url;
   }
@@ -1622,8 +1720,11 @@ function _linkchecker_node_links_missing($nid, $links) {
  *   An array of comment references missing in the linkchecker_comment table.
  */
 function _linkchecker_comment_links_missing($cid, $links) {
-  $result = db_query('SELECT ll.url FROM {linkchecker_link} ll INNER JOIN {linkchecker_comment} lc ON lc.lid = ll.lid WHERE lc.cid = :cid AND ll.urlhash IN (:urlhashes)', array(':cid' => $cid, ':urlhashes' => array_map('drupal_hash_base64', $links)));
-  $links_in_database = array();
+
+  $connection = \Drupal::database();
+  $result = $connection->query('SELECT ll.url FROM {linkchecker_link} ll INNER JOIN {linkchecker_comment} lc ON lc.lid = ll.lid WHERE lc.cid = :cid AND ll.urlhash IN (:urlhashes[])', array(':cid' => $cid, ':urlhashes[]' => array_map('\Drupal\Component\Utility\Crypt::hashBase64', $links)));
+
+  $links_in_database = [];
   foreach ($result as $row) {
     $links_in_database[] = $row->url;
   }
@@ -1643,8 +1744,10 @@ function _linkchecker_comment_links_missing($cid, $links) {
  *   table.
  */
 function _linkchecker_block_custom_links_missing($bid, $links) {
-  $result = db_query('SELECT ll.url FROM {linkchecker_link} ll INNER JOIN {linkchecker_block_custom} lb ON lb.lid = ll.lid WHERE lb.bid = :bid AND ll.urlhash IN (:urlhashes)', array(':bid' => $bid, ':urlhashes' => array_map('drupal_hash_base64', $links)));
-  $links_in_database = array();
+  $connection = \Drupal::database();
+  $result = $connection->query('SELECT ll.url FROM {linkchecker_link} ll INNER JOIN {linkchecker_block_custom} lb ON lb.lid = ll.lid WHERE lb.bid = :bid AND ll.urlhash IN (:urlhashes[])', array(':bid' => $bid, ':urlhashes[]' => array_map('\Drupal\Component\Utility\Crypt::hashBase64', $links)));
+
+  $links_in_database = [];
   foreach ($result as $row) {
     $links_in_database[] = $row->url;
   }
@@ -1672,63 +1775,73 @@ function _linkchecker_block_custom_links_missing($bid, $links) {
  *   Array of field items with filters applied.
  */
 function _linkchecker_parse_fields($entity_type, $bundle_name, $entity, $return_field_names = FALSE) {
-  $text_items = array();
-  $text_items_by_field = array();
+
+  $text_items = [];
+  $text_items_by_field = [];
 
   // Create settings for _filter_url() function.
   $filter = new stdClass();
   $filter->settings['filter_url_length'] = 72;
 
   // Collect the fields from this entity_type and bundle.
-  foreach (field_info_instances($entity_type, $bundle_name) as $field_name => $instance) {
-    $field = field_info_field($field_name);
-    // #1923328: field_name array may be missing in $entity.
-    $entity_field = isset($entity->{$field['field_name']}) ? $entity->{$field['field_name']} : array();
-
-    switch ($field['type']) {
-      // Core fields.
-      case 'text_with_summary':
-        foreach ($entity_field as $language) {
-          foreach ($language as $item) {
-            $item += array(
+  $entityManager = \Drupal::service('entity_field.manager');
+  $fields = $entityManager->getFieldDefinitions($entity_type, $bundle_name);
+
+  foreach ($fields as $field_name => $instance) {
+    if ($instance instanceof FieldConfigInterface ) {
+      $field = FieldStorageConfig::loadByName($entity_type, $field_name);
+      // #1923328: field_name array may be missing in $entity.
+      $entity_field = isset($entity->{$field->getName()}) ? $entity->{$field->getName()} : [];
+
+      switch ($field->getType()) {
+        // Core fields.
+        case 'text_with_summary':
+
+          $field_value = $entity_field->getValue();
+          foreach ($field_value as $item) {
+            $item += [
               'format' => NULL,
               'summary' => '',
               'value' => '',
-            );
-            $text_items[] = $text_items_by_field[$field['field_name']][] = _linkchecker_check_markup($item['value'], $item['format'], linkchecker_entity_language($entity_type, $entity), TRUE);
-            $text_items[] = $text_items_by_field[$field['field_name']][] = _linkchecker_check_markup($item['summary'], $item['format'], linkchecker_entity_language($entity_type, $entity), TRUE);
+            ];
+
+            $text_items[] = $text_items_by_field[$field->getName()][] = _linkchecker_check_markup($item['value'], $item['format'], linkchecker_entity_language($entity_type, $entity), TRUE);
+            $text_items[] = $text_items_by_field[$field->getName()][] = _linkchecker_check_markup($item['summary'], $item['format'], linkchecker_entity_language($entity_type, $entity), TRUE);
           }
-        }
-        break;
+          break;
 
-      // Core fields.
-      case 'text_long':
-      case 'text':
-        foreach ($entity_field as $language) {
-          foreach ($language as $item) {
-            $item += array(
+        // Core fields.
+        case 'text_long':
+        case 'text':
+        case 'string':
+        case 'string_long':
+          $field_value =  $entity_field->getValue();
+
+          foreach ($field_value as $item) {
+            $item += [
               'format' => NULL,
               'value' => '',
-            );
-            $text_items[] = $text_items_by_field[$field['field_name']][] = _linkchecker_check_markup($item['value'], $item['format'], linkchecker_entity_language($entity_type, $entity), TRUE);
+            ];
+            $text_items[] = $text_items_by_field[$field->getName()][] = _linkchecker_check_markup($item['value'], $item['format'], linkchecker_entity_language($entity_type, $entity), TRUE);
           }
-        }
-        break;
+          break;
 
-      // Link module field, http://drupal.org/project/link.
-      case 'link_field':
-        foreach ($entity_field as $language) {
-          foreach ($language as $item) {
-            $item += array(
-              'title' => '',
-            );
-            $options = drupal_parse_url(link_cleanup_url($item['url']));
-            $text_items[] = $text_items_by_field[$field['field_name']][] = l($item['title'], $options['path'], $options);
-            $text_items[] = $text_items_by_field[$field['field_name']][] = _linkchecker_check_markup($item['title'], NULL, linkchecker_entity_language($entity_type, $entity), TRUE);
+        // Link module field, http://drupal.org/project/link.
+        case 'link_field':
+          foreach ($entity_field as $language) {
+            foreach ($language as $item) {
+              $item += [
+                'title' => '',
+              ];
+              $options = drupal_parse_url(link_cleanup_url($item['url']));
+              $text_items[] = $text_items_by_field[$field['field_name']][] = l($item['title'], $options['path'], $options);
+              $text_items[] = $text_items_by_field[$field['field_name']][] = _linkchecker_check_markup($item['title'], NULL, linkchecker_entity_language($entity_type, $entity), TRUE);
+            }
           }
-        }
-        break;
+          break;
+      }
     }
+
   }
 
   return ($return_field_names) ? $text_items_by_field : $text_items;
@@ -1802,11 +1915,12 @@ function _linkchecker_cleanup_links() {
   // Remove disabled node types no longer in use.
   $node_types = linkchecker_scan_node_types();
   if (!empty($node_types)) {
-    $subquery1 = db_select('node', 'n')
-      ->fields('n', array('nid'))
+
+    $subquery1 = \Drupal::database()->select('node', 'n')
+      ->fields('n', ['nid'])
       ->condition('n.type', $node_types, 'NOT IN');
 
-    db_delete('linkchecker_node')
+    \Drupal::database()->delete('linkchecker_node')
       ->condition('nid', $subquery1, 'IN')
       ->execute();
 
@@ -1815,7 +1929,7 @@ function _linkchecker_cleanup_links() {
   }
   else {
     // No active node_type. Remove all items from table.
-    db_truncate('linkchecker_node')->execute();
+    \Drupal::database()->truncate('linkchecker_node')->execute();
     // @todo Remove comments link references from table.
   }
 
@@ -1823,34 +1937,36 @@ function _linkchecker_cleanup_links() {
   // @todo Remove comments of unpublished nodes.
   $comment_types = linkchecker_scan_comment_types();
   if (empty($comment_types)) {
-    db_truncate('linkchecker_comment')->execute();
+    \Drupal::database()->truncate('linkchecker_comment')->execute();
   }
 
   // Remove block link references if block scanning is disabled.
-  if (variable_get('linkchecker_scan_blocks', 0) == 0) {
-    db_truncate('linkchecker_block_custom')->execute();
+  if (\Drupal::config('linkchecker.settings')->get('linkchecker_scan_blocks') == 0) {
+    \Drupal::database()->truncate('linkchecker_block_custom')->execute();
   }
 
   // Remove dead links without references.
-  $linkchecker_node = db_select('linkchecker_node', 'ln')
+  $linkchecker_node = \Drupal::database()->select('linkchecker_node', 'ln')
+
     ->distinct()
-    ->fields('ln', array('lid'));
-  $linkchecker_comment = db_select('linkchecker_comment', 'lc')
+    ->fields('ln', ['lid']);
+
+  $linkchecker_comment = \Drupal::database()->select('linkchecker_comment', 'lc')
     ->distinct()
-    ->fields('lc', array('lid'));
-  $linkchecker_block_custom = db_select('linkchecker_block_custom', 'lb')
+    ->fields('lc', ['lid']);
+
+  $linkchecker_block_custom = \Drupal::database()->select('linkchecker_block_custom', 'lb')
     ->distinct()
-    ->fields('lb', array('lid'));
+    ->fields('lb', ['lid']);
 
   // UNION all linkchecker type tables.
-  $subquery2 = db_select($linkchecker_block_custom->union($linkchecker_comment)->union($linkchecker_node), 'q1')
+  $subquery2 = \Drupal::database()->select($linkchecker_block_custom->union($linkchecker_comment)->union($linkchecker_node), 'q1')
     ->distinct()
-    ->fields('q1', array('lid'));
+    ->fields('q1', ['lid']);
 
-  db_delete('linkchecker_link')
+  \Drupal::database()->delete('linkchecker_link')
     ->condition('lid', $subquery2, 'NOT IN')
     ->execute();
-
 }
 
 /**
@@ -1871,12 +1987,12 @@ function _linkchecker_cleanup_links() {
 function _linkchecker_extract_links($text = '', $content_path = NULL) {
   global $base_root, $is_https;
 
-  $html_dom = filter_dom_load($text);
-  $urls = array();
-
+  $html_dom = Html::load($text);
+  $urls = [];
   // Finds all hyperlinks in the content.
-  if (variable_get('linkchecker_extract_from_a', 1) == 1) {
+  if (\Drupal::config('linkchecker.settings')->get('extract.from_a') == 1) {
     $links = $html_dom->getElementsByTagName('a');
+
     foreach ($links as $link) {
       $urls[] = $link->getAttribute('href');
     }
@@ -1888,7 +2004,7 @@ function _linkchecker_extract_links($text = '', $content_path = NULL) {
   }
 
   // Finds all audio links in the content.
-  if (variable_get('linkchecker_extract_from_audio', 0) == 1) {
+  if (\Drupal::config('linkchecker.settings')->get('extract.from_audio') == 1) {
     $audios = $html_dom->getElementsByTagName('audio');
     foreach ($audios as $audio) {
       $urls[] = $audio->getAttribute('src');
@@ -1907,7 +2023,7 @@ function _linkchecker_extract_links($text = '', $content_path = NULL) {
   }
 
   // Finds embed tags with links in the content.
-  if (variable_get('linkchecker_extract_from_embed', 0) == 1) {
+  if (\Drupal::config('linkchecker.settings')->get('extract.from_embed') == 1) {
     $embeds = $html_dom->getElementsByTagName('embed');
     foreach ($embeds as $embed) {
       $urls[] = $embed->getAttribute('src');
@@ -1917,7 +2033,7 @@ function _linkchecker_extract_links($text = '', $content_path = NULL) {
   }
 
   // Finds iframe tags with links in the content.
-  if (variable_get('linkchecker_extract_from_iframe', 0) == 1) {
+  if (\Drupal::config('linkchecker.settings')->get('extract.from_iframe') == 1) {
     $iframes = $html_dom->getElementsByTagName('iframe');
     foreach ($iframes as $iframe) {
       $urls[] = $iframe->getAttribute('src');
@@ -1925,7 +2041,7 @@ function _linkchecker_extract_links($text = '', $content_path = NULL) {
   }
 
   // Finds img tags with links in the content.
-  if (variable_get('linkchecker_extract_from_img', 0) == 1) {
+  if (\Drupal::config('linkchecker.settings')->get('extract.from_img') == 1) {
     $imgs = $html_dom->getElementsByTagName('img');
     foreach ($imgs as $img) {
       $urls[] = $img->getAttribute('src');
@@ -1934,7 +2050,7 @@ function _linkchecker_extract_links($text = '', $content_path = NULL) {
   }
 
   // Finds object/param tags with links in the content.
-  if (variable_get('linkchecker_extract_from_object', 0) == 1) {
+  if (\Drupal::config('linkchecker.settings')->get('extract.from_object') == 1) {
     $objects = $html_dom->getElementsByTagName('object');
     foreach ($objects as $object) {
       $urls[] = $object->getAttribute('data');
@@ -1946,12 +2062,12 @@ function _linkchecker_extract_links($text = '', $content_path = NULL) {
         // @todo
         // - Try to extract links in unkown "flashvars" values
         //   (e.g., file=http://, data=http://).
-        $names = array('archive', 'filename', 'href', 'movie', 'src', 'url');
+        $names = ['archive', 'filename', 'href', 'movie', 'src', 'url'];
         if ($param->hasAttribute('name') && in_array($param->getAttribute('name'), $names)) {
           $urls[] = $param->getAttribute('value');
         }
 
-        $srcs = array('movie');
+        $srcs = ['movie'];
         if ($param->hasAttribute('src') && in_array($param->getAttribute('src'), $srcs)) {
           $urls[] = $param->getAttribute('value');
         }
@@ -1960,7 +2076,7 @@ function _linkchecker_extract_links($text = '', $content_path = NULL) {
   }
 
   // Finds video tags with links in the content.
-  if (variable_get('linkchecker_extract_from_video', 0) == 1) {
+  if (\Drupal::config('linkchecker.settings')->get('extract.from_video') == 1) {
     $videos = $html_dom->getElementsByTagName('video');
     foreach ($videos as $video) {
       $urls[] = $video->getAttribute('poster');
@@ -1983,11 +2099,10 @@ function _linkchecker_extract_links($text = '', $content_path = NULL) {
   $urls = array_filter($urls);
   // Remove duplicate urls.
   $urls = array_unique($urls);
-
   // What type of links should be checked?
-  $linkchecker_check_links_types = variable_get('linkchecker_check_links_types', 1);
+  $linkchecker_check_links_types = \Drupal::config('linkchecker.settings')->get('check_links_types');
 
-  $links = array();
+  $links = [];
   foreach ($urls as $url) {
     // Decode HTML links into plain text links.
     // DOMDocument->loadHTML does not provide the RAW url from code. All html
@@ -2005,7 +2120,7 @@ function _linkchecker_extract_links($text = '', $content_path = NULL) {
     $url_encoded = str_replace(' ', '%20', $url_decoded);
 
     // Full qualified URLs.
-    if ($linkchecker_check_links_types != 2 && valid_url($url_encoded, TRUE)) {
+    if ($linkchecker_check_links_types != 2 && UrlHelper::isValid($url_encoded, TRUE)) {
       // Add to Array and change HTML links into plain text links.
       $links[$url_decoded][] = $url;
     }
@@ -2014,7 +2129,7 @@ function _linkchecker_extract_links($text = '', $content_path = NULL) {
       continue;
     }
     // Local URLs. $linkchecker_check_links_types = 0 or 2
-    elseif ($linkchecker_check_links_types != 1 && valid_url($url_encoded, FALSE)) {
+    elseif ($linkchecker_check_links_types != 1 && UrlHelper::isValid($url_encoded, FALSE)) {
       // Get full qualified url with base path of content.
       $absolute_content_path = _linkchecker_absolute_content_path($content_path);
 
@@ -2080,21 +2195,21 @@ function _linkchecker_link_replace(&$text, $old_link_fqdn = '', $new_link_fqdn =
   // Don't do any string replacement if one of the values is empty.
   if (!empty($text) && !empty($old_link_fqdn) && !empty($new_link_fqdn)) {
     // Remove protocols and hostname from local URLs.
-    $base_roots = array(
-      drupal_strtolower('http://' . $_SERVER['HTTP_HOST']),
-      drupal_strtolower('https://' . $_SERVER['HTTP_HOST']),
-    );
+    $base_roots = [
+      Unicode::strtolower('http://' . $_SERVER['HTTP_HOST']),
+      Unicode::strtolower('https://' . $_SERVER['HTTP_HOST']),
+    ];
     $old_link = str_replace($base_roots, '', $old_link_fqdn);
     $new_link = str_replace($base_roots, '', $new_link_fqdn);
 
     // Build variables with all URLs and run check_url() only once.
-    $old_html_link_fqdn = check_url($old_link_fqdn);
-    $new_html_link_fqdn = check_url($new_link_fqdn);
-    $old_html_link = check_url($old_link);
-    $new_html_link = check_url($new_link);
+    $old_html_link_fqdn = UrlHelper::filterBadProtocol($old_link_fqdn);
+    $new_html_link_fqdn = UrlHelper::filterBadProtocol($new_link_fqdn);
+    $old_html_link = UrlHelper::filterBadProtocol($old_link);
+    $new_html_link = UrlHelper::filterBadProtocol($new_link);
 
     // Replace links in link fields and text and Links weblink fields.
-    if (in_array($text, array($old_html_link_fqdn, $old_html_link, $old_link_fqdn, $old_link))) {
+    if (in_array($text, [$old_html_link_fqdn, $old_html_link, $old_link_fqdn, $old_link])) {
       // Keep old and new links in the same encoding and format and short or
       // fully qualified.
       $text = str_replace($old_html_link_fqdn, $new_html_link_fqdn, $text);
@@ -2104,11 +2219,11 @@ function _linkchecker_link_replace(&$text, $old_link_fqdn = '', $new_link_fqdn =
     }
     else {
       // Create an array of links with HTML decoded and encoded URLs.
-      $old_links = array(
+      $old_links = [
         $old_html_link_fqdn,
         $old_html_link,
         $old_link,
-      );
+      ];
 
       // Remove duplicate URLs from array if URLs do not have URL parameters.
       // If more than one URL parameter exists - one URL in the array will have
@@ -2117,10 +2232,10 @@ function _linkchecker_link_replace(&$text, $old_link_fqdn = '', $new_link_fqdn =
       $old_links = array_unique($old_links);
 
       // Load HTML code into DOM.
-      $html_dom = filter_dom_load($text);
+      $html_dom = Html::load($text);
 
       // Finds all hyperlinks in the content.
-      if (variable_get('linkchecker_extract_from_a', 1) == 1) {
+      if (\Drupal::config('linkchecker.settings')->get('extract.from_a') == 1) {
         $links = $html_dom->getElementsByTagName('a');
         foreach ($links as $link) {
           if (in_array($link->getAttribute('href'), $old_links)) {
@@ -2142,7 +2257,7 @@ function _linkchecker_link_replace(&$text, $old_link_fqdn = '', $new_link_fqdn =
       }
 
       // Finds all audio links in the content.
-      if (variable_get('linkchecker_extract_from_audio', 0) == 1) {
+      if (\Drupal::config('linkchecker.settings')->get('extract.from_a') == 1) {
         $audios = $html_dom->getElementsByTagName('audio');
         foreach ($audios as $audio) {
           if (in_array($audio->getAttribute('src'), $old_links)) {
@@ -2167,7 +2282,7 @@ function _linkchecker_link_replace(&$text, $old_link_fqdn = '', $new_link_fqdn =
       }
 
       // Finds embed tags with links in the content.
-      if (variable_get('linkchecker_extract_from_embed', 0) == 1) {
+      if (\Drupal::config('linkchecker.settings')->get('extract.from_embed') == 1) {
         $embeds = $html_dom->getElementsByTagName('embed');
         foreach ($embeds as $embed) {
           if (in_array($embed->getAttribute('src'), $old_links)) {
@@ -2183,7 +2298,7 @@ function _linkchecker_link_replace(&$text, $old_link_fqdn = '', $new_link_fqdn =
       }
 
       // Finds iframe tags with links in the content.
-      if (variable_get('linkchecker_extract_from_iframe', 0) == 1) {
+      if (\Drupal::config('linkchecker.settings')->get('extract.from_iframe') == 1) {
         $iframes = $html_dom->getElementsByTagName('iframe');
         foreach ($iframes as $iframe) {
           if (in_array($iframe->getAttribute('src'), $old_links)) {
@@ -2193,7 +2308,7 @@ function _linkchecker_link_replace(&$text, $old_link_fqdn = '', $new_link_fqdn =
       }
 
       // Finds img tags with links in the content.
-      if (variable_get('linkchecker_extract_from_img', 0) == 1) {
+      if (\Drupal::config('linkchecker.settings')->get('extract.from_img') == 1) {
         $imgs = $html_dom->getElementsByTagName('img');
         foreach ($imgs as $img) {
           if (in_array($img->getAttribute('src'), $old_links)) {
@@ -2206,7 +2321,7 @@ function _linkchecker_link_replace(&$text, $old_link_fqdn = '', $new_link_fqdn =
       }
 
       // Finds object/param tags with links in the content.
-      if (variable_get('linkchecker_extract_from_object', 0) == 1) {
+      if (\Drupal::config('linkchecker.settings')->get('extract.from_object') == 1) {
         $objects = $html_dom->getElementsByTagName('object');
         foreach ($objects as $object) {
           if (in_array($object->getAttribute('data'), $old_links)) {
@@ -2222,14 +2337,14 @@ function _linkchecker_link_replace(&$text, $old_link_fqdn = '', $new_link_fqdn =
             // @todo
             // - Try to replace links in unkown "flashvars" values
             //   (e.g., file=http://, data=http://).
-            $names = array('archive', 'filename', 'href', 'movie', 'src', 'url');
+            $names = ['archive', 'filename', 'href', 'movie', 'src', 'url'];
             if ($param->hasAttribute('name') && in_array($param->getAttribute('name'), $names)) {
               if (in_array($param->getAttribute('value'), $old_links)) {
                 $param->setAttribute('value', $new_html_link);
               }
             }
 
-            $srcs = array('movie');
+            $srcs = ['movie'];
             if ($param->hasAttribute('src') && in_array($param->getAttribute('src'), $srcs)) {
               if (in_array($param->getAttribute('value'), $old_links)) {
                 $param->setAttribute('value', $new_html_link);
@@ -2240,7 +2355,7 @@ function _linkchecker_link_replace(&$text, $old_link_fqdn = '', $new_link_fqdn =
       }
 
       // Finds video tags with links in the content.
-      if (variable_get('linkchecker_extract_from_video', 0) == 1) {
+      if (\Drupal::config('linkchecker.settings')->get('extract.from_video') == 1) {
         $videos = $html_dom->getElementsByTagName('video');
         foreach ($videos as $video) {
           if (in_array($video->getAttribute('poster'), $old_links)) {
@@ -2287,8 +2402,10 @@ function _linkchecker_check_markup($text, $format_id = NULL, $langcode = '', $ca
     $format_id = filter_fallback_format();
   }
   // If the requested text format does not exist, the text cannot be filtered.
-  if (!$format = filter_format_load($format_id)) {
-    linkchecker_watchdog_log('filter', 'Missing text format: %format.', array('%format' => $format_id), WATCHDOG_ALERT);
+  /** @var \Drupal\filter\Entity\FilterFormat $format **/
+  $format = FilterFormat::load($format_id);
+  if (!$format) {
+    linkchecker_watchdog_log('filter', 'Missing text format: %format.', ['%format' => $format_id], RfcLogLevel::ALERT);
     return '';
   }
 
@@ -2296,7 +2413,7 @@ function _linkchecker_check_markup($text, $format_id = NULL, $langcode = '', $ca
   $cache = $cache && !empty($format->cache);
   $cache_id = '';
   if ($cache) {
-    $cache_id = 'linkchecker:' . $format->format . ':' . $langcode . ':' . hash('sha256', $text);
+    $cache_id = 'linkchecker:' . $format->id() . ':' . $langcode . ':' . hash('sha256', $text);
     if ($cached = cache_get($cache_id, 'cache_filter')) {
       return $cached->data;
     }
@@ -2307,29 +2424,35 @@ function _linkchecker_check_markup($text, $format_id = NULL, $langcode = '', $ca
   $text = str_replace(array("\r\n", "\r"), "\n", $text);
 
   // Get a complete list of filters, ordered properly.
-  $filters = filter_list_format($format->format);
-  $filter_info = filter_get_filters();
+  /** @var \Drupal\filter\Plugin\FilterInterface[] $filters **/
+  $filters = $format->filters();
+  $filter_info = filter_formats();
 
   // Do not run placeholder or special tag filters used as references to nodes
   // like 'weblink' or 'weblinks' node types. If the original link node is
-  // updated, all links are automatically up-to-date and there is no need to
+  // updated, all links are automatically2 up-to-date and there is no need to
   // notify about the broken link on all nodes having a link reference in
   // content. This would only confuse the authors as they may also not be able
   // to fix the source node of the reference.
-  $filters_blacklist = array_keys(array_filter(variable_get('linkchecker_filter_blacklist', explode('|', LINKCHECKER_DEFAULT_FILTER_BLACKLIST))));
+
+  $filters_blacklist = array_keys(array_filter(\Drupal::config('linkchecker.settings')->get('extract.filter_blacklist')));
 
   // Give filters the chance to escape HTML-like data such as code or formulas.
-  foreach ($filters as $name => $filter) {
+
+  foreach ($filters->getAll() as $filter) {
+    $name = $filter->getType();
+    $status = $filter->status;
+
     if (!in_array($name, $filters_blacklist)) {
-      if ($filter->status && isset($filter_info[$name]['prepare callback']) && function_exists($filter_info[$name]['prepare callback'])) {
+      if ($status && isset($filter_info[$name]['prepare callback']) && function_exists($filter_info[$name]['prepare callback'])) {
         $function = $filter_info[$name]['prepare callback'];
-        $text = $function($text, $filter, $format, $langcode, $cache, $cache_id);
+        $text = $function($text, $filters, $format, $langcode, $cache, $cache_id);
       }
     }
   }
 
   // Perform filtering.
-  foreach ($filters as $name => $filter) {
+  foreach ($filters->getAll() as $name => $filter) {
     if (!in_array($name, $filters_blacklist)) {
       if ($filter->status && isset($filter_info[$name]['process callback']) && function_exists($filter_info[$name]['process callback'])) {
         $function = $filter_info[$name]['process callback'];
@@ -2342,7 +2465,6 @@ function _linkchecker_check_markup($text, $format_id = NULL, $langcode = '', $ca
   if ($cache) {
     cache_set($cache_id, $text, 'cache_filter', REQUEST_TIME + (60 * 60 * 24));
   }
-
   return $text;
 }
 
@@ -2369,7 +2491,7 @@ function _linkchecker_absolute_content_path($url) {
   }
 
   // Break if the schema is not supported.
-  if (!in_array($uri['scheme'], array('http', 'https'))) {
+  if (!in_array($uri['scheme'], ['http', 'https'])) {
     return NULL;
   }
 
@@ -2393,17 +2515,16 @@ function _linkchecker_absolute_content_path($url) {
  * Verifies against blacklists, if the link status should be checked or not.
  */
 function _linkchecker_link_check_status_filter($url) {
-  $status = TRUE;
-
+  $status = 1;
   // Is url in domain blacklist?
-  $urls = variable_get('linkchecker_disable_link_check_for_urls', LINKCHECKER_RESERVED_DOCUMENTATION_DOMAINS);
+  $urls = \Drupal::config('linkchecker.settings')->get('check.disable_link_check_for_urls');
   if (!empty($urls) && preg_match('/' . implode('|', array_map(create_function('$links', 'return preg_quote($links, \'/\');'), preg_split('/(\r\n?|\n)/', $urls))) . '/', $url)) {
-    $status = FALSE;
+    $status = 0;
   }
 
   // Protocol whitelist check (without curl, only http/https is supported).
   if (!preg_match('/^(https?):\/\//i', $url)) {
-    $status = FALSE;
+    $status = 1;
   }
 
   return $status;
@@ -2420,7 +2541,7 @@ function _linkchecker_link_check_status_filter($url) {
  */
 function _linkchecker_isvalid_response_code($code) {
 
-  $responses = array(
+  $responses = [
     100 => 'Continue',
     101 => 'Switching Protocols',
     200 => 'OK',
@@ -2461,7 +2582,7 @@ function _linkchecker_isvalid_response_code($code) {
     503 => 'Service Unavailable',
     504 => 'Gateway Time-out',
     505 => 'HTTP Version not supported',
-  );
+  ];
 
   return array_key_exists($code, $responses);
 }
@@ -2473,9 +2594,9 @@ function _linkchecker_isvalid_response_code($code) {
  *   An array of node type names, keyed by the type.
  */
 function linkchecker_scan_node_types() {
-  $types = array();
+  $types = [];
   foreach (node_type_get_names() as $type => $name) {
-    if (variable_get('linkchecker_scan_node_' . $type, FALSE)) {
+    if (\Drupal::config('linkchecker.settings')->get('linkchecker_scan_node_' . $type)) {
       $types[$type] = $type;
     }
   }
@@ -2489,9 +2610,9 @@ function linkchecker_scan_node_types() {
  *   An array of node type names, keyed by the type.
  */
 function linkchecker_scan_comment_types() {
-  $types = array();
+  $types = [];
   foreach (node_type_get_names() as $type => $name) {
-    if (variable_get('linkchecker_scan_comment_' . $type, FALSE)) {
+    if (\Drupal::config('linkchecker.settings')->get('linkchecker_scan_comment_' . $type)) {
       $types[$type] = $type;
     }
   }
@@ -2505,16 +2626,18 @@ function linkchecker_scan_comment_types() {
  *   A link ID that have reached a defined failcount.
  */
 function _linkchecker_unpublish_nodes($lid) {
-  $result = db_query('SELECT nid FROM {linkchecker_node} WHERE lid = :lid', array(':lid' => $lid));
+  $connection = \Drupal::database();
+  $result = $connection->query('SELECT nid FROM {linkchecker_node} WHERE lid = :lid', [':lid' => $lid]);
+
   foreach ($result as $row) {
-    // Explicitly don't use node_load_multiple() or the module may run
+    // Explicitly don't use Node::load_multiple() or the module may run
     // into issues like http://drupal.org/node/1210606. With this logic
     // nodes can be updated until an out of memory occurs and further
     // updates will be made on the remaining nodes only.
-    $node = node_load($row->nid);
-    $node->status = NODE_NOT_PUBLISHED;
-    node_save($node);
-    linkchecker_watchdog_log('linkchecker', 'Set @type %title to unpublished.', array('@type' => $node->type, '%title' => $node->title));
+    $node = Node::load($row->nid);
+    $node->setPublished(FALSE);
+    $node->save();
+    linkchecker_watchdog_log('linkchecker', 'Set @type %title to unpublished.', ['@type' => $node->bundle(), '%title' => $node->get('title')->value]);
   }
 }
 
@@ -2522,12 +2645,14 @@ function _linkchecker_unpublish_nodes($lid) {
  * Load link as object.
  *
  * @param int $lid
- *  The link id.
+ *   The link id.
  *
  * @return object
  */
 function linkchecker_link_load($lid) {
-  return db_query('SELECT * FROM {linkchecker_link} WHERE lid = :lid', array(':lid' => $lid))->fetchObject();
+  $connection = \Drupal::database();
+  return $connection->query('SELECT * FROM {linkchecker_link} WHERE lid = :lid', [':lid' => $lid])->fetchObject();
+
 }
 
 /**
@@ -2558,13 +2683,13 @@ function _linkchecker_isdefaultrevision($entity) {
   //
   // Every moderation module saving a forward revision needs to return FALSE.
   // @todo: Refactor this workaround under D8.
-
   // Workbench Moderation module.
-  if (module_exists('workbench_moderation') && workbench_moderation_node_type_moderated($entity->type) === TRUE && empty($entity->workbench_moderation['updating_live_revision'])) {
-    return FALSE;
-  }
+  // if (module_exists('workbench_moderation') && workbench_moderation_node_type_moderated($entity->type) === TRUE && empty($entity->workbench_moderation['updating_live_revision'])) {
+  // if (\Drupal::moduleHandler()->moduleExists('workbench_moderation') && ($entity->hasHandlerClass('moderation')) && empty($entity->workbench_moderation['updating_live_revision'])) {
+  //   return FALSE;
+  // }
 
-  return TRUE;
+  //return TRUE;
 }
 
 /**
@@ -2599,7 +2724,7 @@ function linkchecker_entity_language($entity_type, $entity) {
  *   Returns all the values from the input array and indexes the array numerically.
  */
 function _linkchecker_array_values_recursive(array $array) {
-  $array_values = array();
+  $array_values = [];
 
   foreach ($array as $value) {
     if (is_array($value)) {
diff --git a/linkchecker.pages.inc b/linkchecker.pages.inc
index b04349b..6f1155f 100644
--- a/linkchecker.pages.inc
+++ b/linkchecker.pages.inc
@@ -13,7 +13,7 @@
  */
 function linkchecker_admin_report_page() {
 
-  $ignore_response_codes = preg_split('/(\r\n?|\n)/', variable_get('linkchecker_ignore_response_codes', "200\n206\n302\n304\n401\n403"));
+  $ignore_response_codes = preg_split('/(\r\n?|\n)/', \Drupal::config('linkchecker.settings')->get('linkchecker_ignore_response_codes'));
 
   // Search for broken links in nodes and comments and blocks of all users.
   // @todo Try to make UNION'ed subselect resultset smaller.
@@ -55,7 +55,7 @@ function linkchecker_admin_report_page() {
 function linkchecker_user_report_page($account) {
   drupal_set_title($account->name);
 
-  $ignore_response_codes = preg_split('/(\r\n?|\n)/', variable_get('linkchecker_ignore_response_codes', "200\n206\n302\n304\n401\n403"));
+  $ignore_response_codes = preg_split('/(\r\n?|\n)/', \Drupal::config('linkchecker.settings')->get('linkchecker_ignore_response_codes'));
 
   // Build query for broken links in nodes of the current user.
   $subquery2 = db_select('node', 'n');
diff --git a/linkchecker.redirect.inc b/linkchecker.redirect.inc
index 0b1ea20..3f8bf27 100644
--- a/linkchecker.redirect.inc
+++ b/linkchecker.redirect.inc
@@ -4,7 +4,7 @@
  * @file
  * Redirect interface to linkchecker functionalities.
  */
-
+use Drupal\Core\Url;
 /**
  * Implements hook_redirect_insert().
  */
@@ -17,14 +17,13 @@ function linkchecker_redirect_insert($redirect) {
  */
 function linkchecker_redirect_update($redirect) {
   // It's unknown if this is a redirect for HTTP/HTTPS or the encoded urls.
-  $url_http = url($redirect->source, array('absolute' => TRUE, $redirect->source_options));
-  $url_https = url($redirect->source, array('absolute' => TRUE, 'https' => TRUE, $redirect->source_options));
-
+  $url_http = Url::fromUri('internal:' . $redirect->source);
+  $url_https = Url::fromUri('internal:' . $redirect->source, array('https' => TRUE));
   $urls = array(
-    $url_http,
-    $url_https,
-    rawurldecode($url_http),
-    rawurldecode($url_https),
+    $url_http->toString(),
+    $url_https->toString(),
+    rawurldecode($url_http->toString()),
+    rawurldecode($url_https->toString()),
   );
 
   _linkchecker_redirect_reset($urls);
@@ -38,9 +37,8 @@ function linkchecker_redirect_update($redirect) {
  */
 function _linkchecker_redirect_reset($urls = array()) {
   $urls = array_unique($urls);
-
-  $num_updated = db_update('linkchecker_link')
-    ->condition('urlhash', array_map('drupal_hash_base64', $urls))
+  $num_updated = \Drupal::database()->update('linkchecker_link')
+    ->condition('urlhash', array_map('\Drupal\Component\Utility\Crypt::hashBase64', $urls))
     ->condition('fail_count', 0, '>')
     ->condition('status', 1)
     ->fields(array('last_checked' => 0))
diff --git a/linkchecker.routing.yml b/linkchecker.routing.yml
index a2a43e8..2b54ca8 100644
--- a/linkchecker.routing.yml
+++ b/linkchecker.routing.yml
@@ -34,4 +34,4 @@ linkchecker.edit_link_settings_form:
     _admin_route: TRUE
   requirements:
     _custom_access: '\Drupal\linkchecker\Form\LinkCheckerEditLinkSettingsForm::access'
-    linkchecker_link: \d+
+    linkchecker_link: \d+
\ No newline at end of file
diff --git a/linkchecker.services.yml b/linkchecker.services.yml
new file mode 100644
index 0000000..93adbb0
--- /dev/null
+++ b/linkchecker.services.yml
@@ -0,0 +1,6 @@
+services:
+
+  # Linkchecker Module logs
+  logger.channel.linkchecker:
+    parent: 'logger.channel_base'
+    arguments: ['linkchecker']
diff --git a/src/Commands/LinkcheckerCommands.php b/src/Commands/LinkcheckerCommands.php
new file mode 100644
index 0000000..fc2beb4
--- /dev/null
+++ b/src/Commands/LinkcheckerCommands.php
@@ -0,0 +1,136 @@
+<?php
+
+namespace Drupal\linkchecker\Commands;
+
+use Drupal\Core\Config\ConfigFactoryInterface;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
+use Drush\Commands\DrushCommands;
+use Psr\Log\LoggerInterface;
+
+/**
+ * Drush 9 commands for Linkchecker module.
+ */
+class LinkcheckerCommands extends DrushCommands {
+
+  use StringTranslationTrait;
+
+  /**
+   * A config factory for retrieving required config settings.
+   *
+   * @var \Drupal\Core\Config\ConfigFactoryInterface
+   */
+  protected $config;
+
+  /**
+   * The logger.channel.linkchecker service.
+   *
+   * @var \Psr\Log\LoggerInterface
+   */
+  protected $logger;
+
+  /**
+   * LinkcheckerCommands constructor.
+   *
+   * @param \Drupal\Core\Config\ConfigFactoryInterface $config
+   *   A config factory object for retrieving configuration settings.
+   * @param \Psr\Log\LoggerInterface $logger
+   *   The logger service.
+   */
+  public function __construct(
+    ConfigFactoryInterface $config,
+    LoggerInterface $logger
+  ) {
+    parent::__construct();
+    $this->config = $config;
+    $this->logger = $logger;
+  }
+
+  /**
+   * Reanalyzes content for links. Recommended after module has been upgraded.
+   *
+   * @command linkchecker:analyze
+   *
+   * @aliases lca
+   */
+  public function analyze() {
+    // @fixme
+    global $base_url;
+    if ($base_url == 'http://default') {
+      $this->logger()->error('You MUST configure the site $base_url or provide --uri parameter.');
+    }
+
+    // @fixme
+    module_load_include('admin.inc', 'linkchecker');
+
+    // Fake $form_state to leverage _submit function.
+    $form_state = [
+      'values' => ['op' => $this->t('Analyze content for links')],
+      'buttons' => [],
+    ];
+
+    $node_types = linkchecker_scan_node_types();
+    if (!empty($node_types) || \Drupal::config('linkchecker.settings')->get('scan_blocks')) {
+      linkchecker_analyze_links_submit(NULL, $form_state);
+      drush_backend_batch_process();
+    }
+    else {
+      drush_log('No content configured for link analysis.', 'status');
+    }
+  }
+
+  /**
+   * Clears all link data and analyze content for links.
+   *
+   * WARNING: Custom link check settings are deleted.
+   *
+   * @command linkchecker:clear
+   *
+   * @aliases lccl
+   */
+  public function clear() {
+    // @fixme
+    global $base_url;
+    if ($base_url == 'http://default') {
+      $this->logger()->error('You MUST configure the site $base_url or provide --uri parameter.');
+      return;
+    }
+
+    // @fixme
+    module_load_include('admin.inc', 'linkchecker');
+
+    // Fake $form_state to leverage _submit function.
+    $form_state = [
+      'values' => ['op' => $this->t('Clear link data and analyze content for links')],
+      'buttons' => [],
+    ];
+
+    $node_types = linkchecker_scan_node_types();
+    if (!empty($node_types) || \Drupal::config('linkchecker.settings')
+      ->get('scan_blocks')) {
+      linkchecker_clear_analyze_links_submit(NULL, $form_state);
+      drush_backend_batch_process();
+    }
+    else {
+      drush_log('No content configured for link analysis.', 'status');
+    }
+  }
+
+  /**
+   * Check link status.
+   *
+   * @command linkchecker:check
+   *
+   * @aliases lcch
+   */
+  public function check() {
+    drush_log('Starting link checking...', 'info');
+    $run = _linkchecker_check_links();
+    if (!$run) {
+      drush_log('Attempted to re-run link checks while they are already running.', 'warning');
+    }
+    else {
+      drush_log('Finished checking links.', 'completed');
+    }
+  }
+
+}
diff --git a/src/Controller/LinkCheckerAdminReportPage.php b/src/Controller/LinkCheckerAdminReportPage.php
index 27cf549..38eaa6a 100644
--- a/src/Controller/LinkCheckerAdminReportPage.php
+++ b/src/Controller/LinkCheckerAdminReportPage.php
@@ -4,14 +4,190 @@ namespace Drupal\linkchecker\Controller;
 
 use Drupal\Core\Session\AccountInterface;
 use Symfony\Component\HttpFoundation\Request;
+use Drupal\Core\Url;
+use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Core\Controller\ControllerBase;
 
 /**
  * Builds admin broken link report page.
  */
-class LinkCheckerAdminReportPage {
+class LinkCheckerAdminReportPage  extends ControllerBase {
 
   public function content() {
-    return '@TODO';
+
+    $ignore_response_codes = preg_split('/(\r\n?|\n)/', \Drupal::config('linkchecker.settings')->get('error.ignore_response_codes'));
+
+    // Search for broken links in nodes and comments and blocks of all users.
+    // @todo Try to make UNION'ed subselect resultset smaller.
+
+    $subquery4 = \Drupal::database()->select('linkchecker_node', 'ln')
+        ->distinct()
+        ->fields('ln', ['lid']);
+
+    $subquery3 = \Drupal::database()->select('linkchecker_comment', 'lc')
+        ->distinct()
+        ->fields('lc', ['lid']);
+
+    $subquery2 = \Drupal::database()->select('linkchecker_block_custom', 'lb')
+        ->distinct()
+        ->fields('lb', ['lid']);
+
+    // UNION all linkchecker type tables.
+
+    $subquery1 = \Drupal::database()->select($subquery2->union($subquery3)->union($subquery4), 'q1')->fields('q1', ['lid']);
+
+    // Build pager query.
+
+    $query = \Drupal::database()->select('linkchecker_link', 'll');
+    $query->innerJoin($subquery1, 'q2', 'q2.lid = ll.lid');
+    $query->fields('ll');
+    $query->condition('ll.last_checked', 0, '<>');
+    $query->condition('ll.status', 1);
+    $query->condition('ll.code', $ignore_response_codes, 'NOT IN');
+    $query->extend('Drupal\Core\Database\Query\PagerSelectExtender')
+           ->extend('Drupal\Core\Database\Query\TableSortExtender');
+
+    return $this->_linkchecker_report_page($query);
+
+  }
+
+  /**
+   * Builds the HTML report page table with pager.
+   *
+   * @param SelectQueryInterface $query
+   *   The pager query for the report page. Can be per user report or global.
+   * @param object|null $account
+   *   The user account object.
+   *
+   * @return string
+   *   Themed report page.
+   */
+
+   public function _linkchecker_report_page($query, $account = NULL) {
+
+    $connection = \Drupal::database();
+    $links_unchecked = $connection->query('SELECT COUNT(1) FROM {linkchecker_link} WHERE last_checked = :last_checked AND status = :status', [':last_checked' => 0, ':status' => 1])->fetchField();
+
+    if ($links_unchecked > 0) {
+      $links_all = $connection->query('SELECT COUNT(1) FROM {linkchecker_link} WHERE status = :status', [':status' => 1])->fetchField();
+
+      drupal_set_message(\Drupal::translation()->formatPlural($links_unchecked,
+          'There is 1 unchecked link of about @links_all links in the database. Please be patient until all links have been checked via cron.',
+          'There are @count unchecked links of about @links_all links in the database. Please be patient until all links have been checked via cron.',
+          ['@links_all' => $links_all]), 'warning');
+    }
+
+    $header = [
+        ['data' => t('URL'), 'field' => 'url', 'sort' => 'desc'],
+        ['data' => t('Response'), 'field' => 'code', 'sort' => 'desc'],
+        ['data' => t('Error'), 'field' => 'error'],
+        ['data' => t('Operations')],
+    ];
+
+    $result = $query
+        ->range(0, 50)
+        ->execute();
+
+    // Evaluate permission once for performance reasons.
+     $account = \Drupal::currentUser();
+    $access_edit_link_settings = $account->hasPermission('edit link settings');
+    $access_administer_blocks = $account->hasPermission('administer blocks');
+    $access_administer_redirects = $account->hasPermission('administer redirects');
+
+    $rows = [];
+    foreach ($result as $link) {
+      // Get the node, block and comment IDs that refer to this broken link and
+      // that the current user has access to.
+      $cids = _linkchecker_link_comment_ids($link, $account);
+      $bids = _linkchecker_link_block_ids($link);
+
+      $nids = $connection->query('SELECT nid  FROM {linkchecker_node} WHERE lid = :lid', [':lid' => $link->lid])->fetchCol();
+
+      // If the user does not have access to see this link anywhere, do not
+      // display it, for reasons explained in _linkchecker_link_access(). We
+      // still need to fill the table row, though, so as not to throw off the
+      // number of items in the pager.
+      if (empty($nids) && empty($cids) && empty($bids)) {
+        $rows[] = array(array('data' => t('Permission restrictions deny you access to this broken link.'), 'colspan' => count($header)));
+        continue;
+      }
+      $links = array();
+
+      // Show links to link settings.
+     // if ($access_edit_link_settings) {
+
+       // $links[] = $this->l(t('Edit link settings'), Url::fromUri('base:' . 'linkchecker/' . $link->lid . '/edit'), array('query' => drupal_get_destination()));
+      //}
+
+      // Show link to nodes having this broken link.
+      foreach ($nids as $nid) {
+        $links[] = $this->l(t('Edit node @node', array('@node' => $nid)), Url::fromUri('base:' . 'node/' . $nid . '/edit'), array('query' => drupal_get_destination()));
+      }
+
+      // Show link to comments having this broken link.
+      $comment_types = linkchecker_scan_comment_types();
+      if (\Drupal::moduleHandler()->moduleExists('comment') && !empty($comment_types)) {
+        foreach ($cids as $cid) {
+          $links[] = $this->l(t('Edit comment @comment', array('@comment' => $cid)), Url::fromUri('base:' . 'comment/' . $cid . '/edit'), array('query' => drupal_get_destination()));
+        }
+      }
+
+      // Show link to blocks having this broken link.
+      if ($access_administer_blocks) {
+        foreach ($bids as $bid) {
+          $links[] = $this->l(t('Edit block @block', array('@block' => $bid)), Url::fromUri('base:' . 'admin/structure/block/manage/block/' . $bid . '/configure') , array('query' => drupal_get_destination()));
+        }
+      }
+
+      // Show link to redirect this broken internal link.
+      if (\Drupal::moduleHandler()->moduleExists('redirect') && $access_administer_redirects  && $this->_linkchecker_is_internal_url($link)) {
+        $links[] = $this->l(t('Create redirection'), Url::fromUri('base:' . 'admin/config/search/redirect/add'), array('query' => array('source' => $link->internal, drupal_get_destination())));
+      }
+
+      // Create table data for output.
+      $items = array(
+          '#theme' => 'item_list',
+          '#items' => $links,
+          '#title' => t(''),
+      );
+
+      $rows[] = array(
+          'data' => array(
+              $this->l(_filter_url_trim($link->url, 60), Url::fromUri($link->url)),
+              $link->code,
+              SafeMarkup::checkPlain($link->error),
+              drupal_render($items),
+          ),
+      );
+    }
+
+    $build['linkchecker_table'] = array(
+        '#theme' => 'table',
+        '#header' => $header,
+        '#rows' => $rows,
+        '#empty' => t('No broken links have been found.'),
+    );
+    $build['linkchecker_pager'] = ['#theme' => 'pager'];
+
+    return $build;
+  }
+
+  /**
+   * Check if the link is an internal URL or not.
+   *
+   * @param object $link
+   *   Link object.
+   *
+   * @return bool
+   *   TRUE if link is internal, otherwise FALSE.
+   */
+  public function _linkchecker_is_internal_url(&$link) {
+    global $base_url;
+
+    if (strpos($link->url, $base_url) === 0) {
+      $link->internal = trim(substr($link->url, strlen($base_url)), " \t\r\n\0\\/");
+      return TRUE;
+    }
   }
 
 }
diff --git a/src/Form/LinkCheckerAdminSettingsForm.php b/src/Form/LinkCheckerAdminSettingsForm.php
index f49ae59..7ac0374 100644
--- a/src/Form/LinkCheckerAdminSettingsForm.php
+++ b/src/Form/LinkCheckerAdminSettingsForm.php
@@ -120,7 +120,7 @@ class LinkCheckerAdminSettingsForm extends ConfigFormBase {
     $filter_descriptions = [];
     foreach ($filter_info as $name => $filter) {
       if (in_array($name, explode('|', LINKCHECKER_DEFAULT_FILTER_BLACKLIST))) {
-        $filter_options[$name] = $this->t('@title <span class="marker">(Recommended)</span>', array('@title' => $filter->getLabel()));
+        $filter_options[$name] = $this->t('@title <span class="marker">(Recommended)</span>', ['@title' => $filter->getLabel()]);
       }
       else {
         $filter_options[$name] = $filter->getLabel();
@@ -138,14 +138,16 @@ class LinkCheckerAdminSettingsForm extends ConfigFormBase {
     ];
     $form['tag']['linkchecker_filter_blacklist'] = array_merge($form['tag']['linkchecker_filter_blacklist'], $filter_descriptions);
 
-    $count_lids_enabled = db_query("SELECT count(lid) FROM {linkchecker_link} WHERE status = :status", array(':status' => 1))->fetchField();
-    $count_lids_disabled = db_query("SELECT count(lid) FROM {linkchecker_link} WHERE status = :status", array(':status' => 0))->fetchField();
-    $form['check'] = [
+    $count_lids_enabled = db_query("SELECT count(lid) FROM {linkchecker_link} WHERE status = :status", [':status' => 1])->fetchField();
+    $count_lids_disabled = db_query("SELECT count(lid) FROM {linkchecker_link} WHERE status = :status", [':status' => 0])->fetchField();
+
+    // httprl module does not exists yet for D8
+    /* $form['check'] = [
       '#type' => 'details',
       '#title' => $this->t('Check settings'),
       '#description' => $this->t('For simultaneous link checks it is recommended to install the <a href=":httprl">HTTP Parallel Request & Threading Library</a>. This may be <strong>necessary</strong> on larger sites with very many links (30.000+), but will also improve overall link check duration on smaller sites. Currently the site has @count links (@count_enabled enabled / @count_disabled disabled).', [':httprl' => 'http://drupal.org/project/httprl', '@count' => $count_lids_enabled+$count_lids_disabled, '@count_enabled' => $count_lids_enabled, '@count_disabled' => $count_lids_disabled]),
       '#open' => TRUE,
-    ];
+    ];*/
     $form['check']['linkchecker_check_library'] = [
       '#type' => 'select',
       '#title' => $this->t('Check library'),
@@ -153,7 +155,7 @@ class LinkCheckerAdminSettingsForm extends ConfigFormBase {
       '#default_value' => $config->get('check.library'),
       '#options' => [
         'core' => $this->t('Drupal core'),
-        'httprl' => $this->t('HTTP Parallel Request & Threading Library'),
+        // 'httprl' => $this->t('HTTP Parallel Request & Threading Library'),
       ],
     ];
     $form['check']['linkchecker_check_connections_max'] = [
@@ -195,9 +197,9 @@ class LinkCheckerAdminSettingsForm extends ConfigFormBase {
       '#default_value' => $config->get('check.disable_link_check_for_urls'),
       '#type' => 'textarea',
       '#title' => $this->t('Do not check the link status of links containing these URLs'),
-      '#description' => $this->t('By default this list contains the domain names reserved for use in documentation and not available for registration. See <a href=":rfc-2606">RFC 2606</a>, Section 3 for more information. URLs on this list are still extracted, but the link setting <em>Check link status</em> becomes automatically disabled to prevent false alarms. If you change this list you need to clear all link data and re-analyze your content. Otherwise this setting will only affect new links added after the configuration change.', array(':rfc-2606' => 'http://www.rfc-editor.org/rfc/rfc2606.txt')),
+      '#description' => $this->t('By default this list contains the domain names reserved for use in documentation and not available for registration. See <a href=":rfc-2606">RFC 2606</a>, Section 3 for more information. URLs on this list are still extracted, but the link setting <em>Check link status</em> becomes automatically disabled to prevent false alarms. If you change this list you need to clear all link data and re-analyze your content. Otherwise this setting will only affect new links added after the configuration change.', [':rfc-2606' => 'http://www.rfc-editor.org/rfc/rfc2606.txt']),
     ];
-    //@fixme: constants no longer exists.
+    // @fixme: constants no longer exists.
     $form['check']['linkchecker_logging_level'] = [
       '#default_value' => $config->get('logging.level'),
       '#type' => 'select',
@@ -222,7 +224,7 @@ class LinkCheckerAdminSettingsForm extends ConfigFormBase {
     $form['error']['linkchecker_impersonate_account'] = [
       '#type' => 'textfield',
       '#title' => $this->t('Impersonate user account'),
-      '#description' => $this->t('If below error handling actions are executed they can be impersonated with a custom user account. By default this is user %name, but you are able to assign a custom user to allow easier identification of these automatic revision updates. Make sure you select a user with <em>full</em> permissions on your site or the user may not able to access and save all content.', array('%name' => $linkchecker_default_impersonate_account->getAccountName())),
+      '#description' => $this->t('If below error handling actions are executed they can be impersonated with a custom user account. By default this is user %name, but you are able to assign a custom user to allow easier identification of these automatic revision updates. Make sure you select a user with <em>full</em> permissions on your site or the user may not able to access and save all content.', ['%name' => $linkchecker_default_impersonate_account->getAccountName()]),
       '#size' => 30,
       '#maxlength' => 60,
       '#autocomplete_path' => 'user/autocomplete',
@@ -230,7 +232,7 @@ class LinkCheckerAdminSettingsForm extends ConfigFormBase {
     ];
     $form['error']['linkchecker_action_status_code_301'] = [
       '#title' => $this->t('Update permanently moved links'),
-      '#description' => $this->t('If enabled, outdated links in content providing a status <em>Moved Permanently</em> (status code 301) are automatically updated to the most recent URL. If used, it is recommended to use a value of <em>three</em> to make sure this is not only a temporarily change. This feature trust sites to provide a valid permanent redirect. A new content revision is automatically created on link updates if <em>create new revision</em> is enabled in the <a href=":content_types">content types</a> publishing options. It is recommended to create new revisions for all link checker enabled content types. Link updates are nevertheless always logged in <a href=":dblog">recent log entries</a>.', array(':dblog' => Url::fromRoute('dblog.overview')->toString(), ':content_types' => Url::fromRoute('entity.node_type.collection')->toString())),
+      '#description' => $this->t('If enabled, outdated links in content providing a status <em>Moved Permanently</em> (status code 301) are automatically updated to the most recent URL. If used, it is recommended to use a value of <em>three</em> to make sure this is not only a temporarily change. This feature trust sites to provide a valid permanent redirect. A new content revision is automatically created on link updates if <em>create new revision</em> is enabled in the <a href=":content_types">content types</a> publishing options. It is recommended to create new revisions for all link checker enabled content types. Link updates are nevertheless always logged in <a href=":dblog">recent log entries</a>.', [':dblog' => Url::fromRoute('dblog.overview')->toString(), ':content_types' => Url::fromRoute('entity.node_type.collection')->toString()]),
       '#type' => 'select',
       '#default_value' => $config->get('error.action_status_code_301'),
       '#options' => [
@@ -310,7 +312,8 @@ class LinkCheckerAdminSettingsForm extends ConfigFormBase {
 
     // Validate impersonation user name.
     $linkchecker_impersonate_account = user_load_by_name($form_state->getValue('linkchecker_impersonate_account'));
-    if (empty($linkchecker_impersonate_account->id())) {
+
+    if ($linkchecker_impersonate_account && empty($linkchecker_impersonate_account->id())) {
       $form_state->setErrorByName('linkchecker_impersonate_account', $this->t('User account %name cannot found.', ['%name' => $form_state->getValue('linkchecker_impersonate_account')]));
     }
   }
@@ -380,10 +383,11 @@ class LinkCheckerAdminSettingsForm extends ConfigFormBase {
    * blocks.
    */
   function submitClearAnalyzeLinks(array &$form, FormStateInterface $form_state) {
-    db_truncate('linkchecker_block_custom')->execute();
-    db_truncate('linkchecker_comment')->execute();
-    db_truncate('linkchecker_node')->execute();
-    db_truncate('linkchecker_link')->execute();
+
+    \Drupal::database()->truncate('linkchecker_block_custom')->execute();
+    \Drupal::database()->truncate('linkchecker_comment')->execute();
+    \Drupal::database()->truncate('linkchecker_node')->execute();
+    \Drupal::database()->truncate('linkchecker_link')->execute();
 
     // Start batch and analyze all nodes.
     $node_types = linkchecker_scan_node_types();
diff --git a/src/Form/LinkCheckerEditLinkSettingsForm.php b/src/Form/LinkCheckerEditLinkSettingsForm.php
index d020b06..af12fa5 100644
--- a/src/Form/LinkCheckerEditLinkSettingsForm.php
+++ b/src/Form/LinkCheckerEditLinkSettingsForm.php
@@ -20,7 +20,12 @@ class LinkCheckerEditLinkSettingsForm {
     $form['settings'] = [
       '#type' => 'details',
       '#title' => $this->t('Settings'),
-      '#description' => $this->t('The link <a href=":url">:url</a> was last checked on @last_checked and failed @fail_count times.', [':url' => $link->url, '@fail_count' => $link->fail_count, '@last_checked' => DateFormatter::format($link->last_checked)]),
+      '#description' => $this->t('The link <a href=":url">:url</a> was last checked on @last_checked and failed @fail_count times.',
+        [
+          ':url' => $link->url,
+          '@fail_count' => $link->fail_count,
+          '@last_checked' => DateFormatter::format($link->last_checked),LinkCheckerAdminSettingsForm.ph
+        ]),
       '#open' => TRUE,
     ];
 
@@ -67,36 +72,36 @@ class LinkCheckerEditLinkSettingsForm {
   public function submitForm(array &$form, FormStateInterface $form_state) {
     // Force link re-check asap.
     if ($form_state->getValue('recheck')) {
-      db_update('linkchecker_link')
+      \Drupal::database()->update('linkchecker_link')
         ->condition('lid', $form_state->getValue('lid'))
-        ->fields(array('last_checked' => 0))
+        ->fields(['last_checked' => 0])
         ->execute();
       drupal_set_message(t('The link %url will be checked again on the next cron run.', ['%url' => $form_state->getValue('url')]));
     }
 
     if ($form_state->getValue('method') != $form['settings']['method']['#default_value']) {
       // Update settings and reset statistics for a quick re-check.
-      db_update('linkchecker_link')
+      \Drupal::database()->update('linkchecker_link')
         ->condition('lid', $form_state->getValue('lid'))
-        ->fields(array(
+        ->fields([
           'method' => $form_state->getValue('method'),
           'fail_count' => 0,
           'last_checked' => 0,
           'status' => $form_state->getValue('status'),
-        ))
+        ])
         ->execute();
-      drupal_set_message(t('The link settings for %url have been saved and the fail counter has been reset.', array('%url' => $form_state->getValue('url'))));
+      drupal_set_message(t('The link settings for %url have been saved and the fail counter has been reset.', ['%url' => $form_state->getValue('url')]));
     }
     else {
       // Update setting only.
-      db_update('linkchecker_link')
+      \Drupal::database()->update('linkchecker_link')
         ->condition('lid', $form_state->getValue('lid'))
-        ->fields(array(
+        ->fields([
           'method' => $form_state->getValue('method'),
           'status' => $form_state->getValue('status'),
-        ))
+        ])
         ->execute();
-      drupal_set_message(t('The link settings for %url have been saved.', array('%url' => $form_state->getValue('url'))));
+      drupal_set_message(t('The link settings for %url have been saved.', ['%url' => $form_state->getValue('url')]));
     }
   }
 
@@ -105,13 +110,14 @@ class LinkCheckerEditLinkSettingsForm {
    *
    * @param \Drupal\Core\Session\AccountInterface $account
    *   Run access checks for this account.
+   *
+   * @FIXME
    */
-  // @FIXME
   public function access($link) {
     // Check permissions and combine that with any custom access checking needed. Pass forward
     // parameters from the route and/or request as needed.
+    $account = \Drupal::currentUser();
     return AccessResult::allowedIf($account->hasPermission('edit link settings') && _linkchecker_link_access($link));
-        //$this->someOtherCustomCondition());
   }
 
 }
