diff --git a/image_captcha/image_captcha.links.task.yml b/image_captcha/image_captcha.links.task.yml
new file mode 100755
index 0000000..3f25d46
--- /dev/null
+++ b/image_captcha/image_captcha.links.task.yml
@@ -0,0 +1,4 @@
+image_captcha.settings:
+  route_name: image_captcha.settings
+  title: 'Image CAPTCHA'
+  base_route: captcha_settings
diff --git a/image_captcha/src/Controller/CaptchaFontPreview.php b/image_captcha/src/Controller/CaptchaFontPreview.php
index 768f78f..7ed7489 100755
--- a/image_captcha/src/Controller/CaptchaFontPreview.php
+++ b/image_captcha/src/Controller/CaptchaFontPreview.php
@@ -27,14 +27,12 @@ class CaptchaFontPreview extends StreamedResponse {
       // Get the mapping of font tokens to font file objects.
       $fonts = \Drupal::config('image_captcha.settings')
         ->get('image_captcha_fonts_preview_map_cache');
-      $config = \Drupal::config('captcha.settings');
-      $fonts = $config->get('image_captcha_fonts_preview_map_cache');
       if (!isset($fonts[$token])) {
         echo 'bad token';
         exit();
       }
       // Get the font path.
-      $font = $fonts[$token]->uri;
+      $font = $fonts[$token]['uri'];
       // Some sanity checks if the given font is valid.
       if (!is_file($font) || !is_readable($font)) {
         echo 'bad font';
@@ -66,7 +64,7 @@ class CaptchaFontPreview extends StreamedResponse {
       imagettftext($image, $font_size, 0, 1, 1.5 * $font_size, $color, realpath($font), $text);
     }
     // Set content type.
-    drupal_add_http_header('Content-Type', 'image/png');
+    $this->headers->set('Content-Type', 'image/png');
     // Dump image data to client.
     imagepng($image);
     // Release image memory.
diff --git a/image_captcha/src/Form/ImageCaptchaSettingsForm.php b/image_captcha/src/Form/ImageCaptchaSettingsForm.php
index 63ed1c1..51289e5 100755
--- a/image_captcha/src/Form/ImageCaptchaSettingsForm.php
+++ b/image_captcha/src/Form/ImageCaptchaSettingsForm.php
@@ -10,6 +10,12 @@ namespace Drupal\image_captcha\Form;
 use Drupal\Core\Form\ConfigFormBase;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Language\Language;
+use Drupal\Core\Language\LanguageManagerInterface;
+use Drupal\Core\Template\Attribute;
+use Drupal\Core\Url;
+use Drupal\Core\DrupalKernel;
+use Drupal\Core\Config\ConfigFactoryInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
  * Displays the pants settings form.
@@ -17,6 +23,36 @@ use Drupal\Core\Language\Language;
 class ImageCaptchaSettingsForm extends ConfigFormBase {
 
   /**
+   * The language manager.
+   *
+   * @var \Drupal\Core\Language\LanguageManagerInterface
+   */
+  protected $languageManager;
+
+  /**
+   * Constructs a \Drupal\image_captcha\Form\ImageCaptchaSettingsForm object.
+   *
+   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
+   *   The factory for configuration objects.
+   * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
+   *   The language manager.
+   */
+  public function __construct(ConfigFactoryInterface $config_factory, LanguageManagerInterface $language_manager) {
+    parent::__construct($config_factory);
+    $this->languageManager = $language_manager;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container) {
+    return new static(
+      $container->get('config.factory'),
+      $container->get('language_manager')
+    );
+  }
+
+  /**
    * {@inheritdoc}
    */
   public function getFormId() {
@@ -41,10 +77,9 @@ class ImageCaptchaSettingsForm extends ConfigFormBase {
     // First some error checking.
     $setup_status = _image_captcha_check_setup(FALSE);
     if ($setup_status & IMAGE_CAPTCHA_ERROR_NO_GDLIB) {
-      drupal_set_message(t(
-        'The Image CAPTCHA module can not generate images because your PHP setup does not support it (no <a href="!gdlib" target="_blank">GD library</a> with JPEG support).',
-        ['!gdlib' => 'http://php.net/manual/en/book.image.php']
-      ), 'error');
+      drupal_set_message(t('The Image CAPTCHA module can not generate images because your PHP setup does not support it (no <a href=":gdlib" target="_blank">GD library</a> with JPEG support).', [
+        ':gdlib' => 'http://php.net/manual/en/book.image.php',
+      ]), 'error');
       // It is no use to continue building the rest of the settings form.
       return $form;
     }
@@ -80,8 +115,8 @@ class ImageCaptchaSettingsForm extends ConfigFormBase {
       '#description' => t('The code length influences the size of the image. Note that larger values make the image generation more CPU intensive.'),
     ];
     // RTL support option (only show this option when there are RTL languages).
-    $languages = language_list('direction');
-    if (isset($languages[Language::DIRECTION_RTL])) {
+    $language = $this->languageManager->getCurrentLanguage();
+    if ($language->getDirection() == Language::DIRECTION_RTL) {
       $form['image_captcha_code_settings']['image_captcha_rtl_support'] = [
         '#title' => t('RTL support'),
         '#type' => 'checkbox',
@@ -231,7 +266,9 @@ class ImageCaptchaSettingsForm extends ConfigFormBase {
       }
       list($readable_fonts, $problem_fonts) = _image_captcha_check_fonts($fonts);
       if (count($problem_fonts) > 0) {
-        $form_state->setErrorByName('image_captcha_fonts', t('The following fonts are not readable: %fonts.', ['%fonts' => implode(', ', $problem_fonts)]));
+        $form_state->setErrorByName('image_captcha_fonts', t('The following fonts are not readable: %fonts.', [
+          '%fonts' => implode(', ', $problem_fonts),
+        ]));
       }
     }
 
@@ -253,10 +290,12 @@ class ImageCaptchaSettingsForm extends ConfigFormBase {
     if (!isset($form['image_captcha_font_settings']['no_ttf_support'])) {
       // Filter the image_captcha fonts array to pick out the selected ones.
       $fonts = array_filter($form_state->getValue('image_captcha_fonts'));
-      $this->config('image_captcha.settings')->set('image_captcha_fonts', $fonts)->save();
+      $this->config('image_captcha.settings')
+        ->set('image_captcha_fonts', $fonts)
+        ->save();
     }
 
-    parent::SubmitForm($form, $form_state);
+    parent::submitForm($form, $form_state);
   }
 
   /**
@@ -296,36 +335,48 @@ class ImageCaptchaSettingsForm extends ConfigFormBase {
       // Cache the list of previewable fonts. All the previews are done
       // in separate requests, and we don't want to rescan the filesystem
       // every time, so we cache the result.
-      $config->get('image_captcha_fonts_preview_map_cache', $fonts);
+      $config->set('image_captcha_fonts_preview_map_cache', $fonts);
+      $config->save();
       // Put these fonts with preview image in the list.
       foreach ($fonts as $token => $font) {
-        $img_src = check_url(url('admin/config/people/captcha/image_captcha/font_preview/' . $token));
-        $title = t('Font preview of @font (@file)', ['@font' => $font->name, '@file' => $font->uri]);
-        $available_fonts[$font->uri] = '<img src="' . $img_src . '" alt="' . $title . '" title="' . $title . '" />';
+        $title = t('Font preview of @font (@file)', [
+          '@font' => $font['name'],
+          '@file' => $font['uri'],
+        ]);
+        $attributes = [
+          'src' => Url::fromRoute('image_captcha.font_preview', ['token' => $token])
+            ->toString(),
+          'title' => $title,
+          'alt' => $title,
+        ];
+        $available_fonts[$font['uri']] = '<img' . new Attribute($attributes) . ' />';
       }
 
       // Append the PHP built-in font at the end.
-      $img_src = check_url(url('admin/config/people/captcha/image_captcha/font_preview/BUILTIN'));
       $title = t('Preview of built-in font');
-      $available_fonts['BUILTIN'] = t('PHP built-in font: !font_preview',
-        ['!font_preview' => '<img src="' . $img_src . '" alt="' . $title . '" title="' . $title . '" />']
-      );
+      $attributes = [
+        'src' => Url::fromRoute('image_captcha.font_preview', ['token' => 'BUILTIN'])
+          ->toString(),
+        'alt' => $title,
+        'title' => $title,
+      ];
+      $available_fonts['BUILTIN'] = (string) t('PHP built-in font: font_preview', [
+        'font_preview' => '<img' . new Attribute($attributes) . ' />',
+      ]);
 
       $default_fonts = _image_captcha_get_enabled_fonts();
+      $conf_path = DrupalKernel::findSitePath($this->getRequest());
       $form['image_captcha_fonts'] = [
         '#type' => 'checkboxes',
         '#title' => t('Fonts'),
         '#default_value' => $default_fonts,
-        '#description' => t('Select the fonts to use for the text in the image CAPTCHA. Apart from the provided defaults, you can also use your own TrueType fonts (filename extension .ttf) by putting them in %fonts_library_general or %fonts_library_specific.',
-          [
-            '%fonts_library_general' => 'sites/all/libraries/fonts',
-            '%fonts_library_specific' => conf_path() . '/libraries/fonts',
-          ]
-        ),
+        '#description' => t('Select the fonts to use for the text in the image CAPTCHA. Apart from the provided defaults, you can also use your own TrueType fonts (filename extension .ttf) by putting them in %fonts_library_general or %fonts_library_specific.', [
+          '%fonts_library_general' => 'sites/all/libraries/fonts',
+          '%fonts_library_specific' => $conf_path . '/libraries/fonts',
+        ]),
         '#options' => $available_fonts,
         '#attributes' => ['class' => ['image_captcha_admin_fonts_selection']],
-        '#process' => ['form_process_checkboxes'],
-        ];
+      ];
 
       $form['image_captcha_font_size'] = [
         '#type' => 'select',
@@ -383,14 +434,15 @@ class ImageCaptchaSettingsForm extends ConfigFormBase {
       $directories = [
         drupal_get_path('module', 'image_captcha') . '/fonts',
         'sites/all/libraries/fonts',
-        conf_path() . '/libraries/fonts',
+        DrupalKernel::findSitePath($this->getRequest()) . '/libraries/fonts',
       ];
     }
     // Collect the font information.
     $fonts = [];
     foreach ($directories as $directory) {
-      foreach (file_scan_directory($directory, '/\.[tT][tT][fF]$/') as $filename => $font) {
-        $fonts[md5($filename)] = $font;
+      $files = file_scan_directory($directory, '/\.[tT][tT][fF]$/');
+      foreach ($files as $filename => $font) {
+        $fonts[md5($filename)] = (array) $font;
       }
     }
 
