diff --git a/custom_text.info b/custom_text.info
deleted file mode 100644
index 6af83df..0000000
--- a/custom_text.info
+++ /dev/null
@@ -1,2 +0,0 @@
-name = Custom Text
-description = Provides a backend and admin interface for custom texts that can be used in other modules and templates.
diff --git a/custom_text.info.yml b/custom_text.info.yml
index e69de29..c4c8dbe 100644
--- a/custom_text.info.yml
+++ b/custom_text.info.yml
@@ -0,0 +1,6 @@
+name: Custom Text
+description: Provides a backend and admin interface for custom texts that can be used in other modules and templates.
+package: Other
+type: module
+version: 1.0
+core: 8.x
\ No newline at end of file
diff --git a/custom_text.install b/custom_text.install
index ef2d008..e9459b3 100644
--- a/custom_text.install
+++ b/custom_text.install
@@ -8,20 +8,18 @@
  * Implements hook_schema(). 
  */
 function custom_text_schema() {
-  $schema = array();
-
   $schema['custom_text'] = array(
     'description' => 'Custom texts to be used in the website.',
     'fields' => array(
       'identifier' => array(
         'description' => 'A unique identifier',
-        'type' => 'varchar',
+        'type' => 'varchar_ascii',
         'length' => 255,
         'not null' => TRUE,
       ),
       'language' => array(
         'description' => 'The {languages}.language of this node.',
-        'type' => 'varchar',
+        'type' => 'varchar_ascii',
         'length' => 12,
         'not null' => TRUE,
       ),
@@ -51,4 +49,4 @@ function custom_text_schema() {
   );
 
   return $schema;
-}
+}
\ No newline at end of file
diff --git a/custom_text.links.menu.yml b/custom_text.links.menu.yml
index e69de29..62a5ebe 100644
--- a/custom_text.links.menu.yml
+++ b/custom_text.links.menu.yml
@@ -0,0 +1,5 @@
+custom_text.config_form:
+  title: Custom Text
+  parent: system.admin_structure
+  description: 'Edit custom texts used throughout the website.'
+  route_name: custom_text.config_form
\ No newline at end of file
diff --git a/custom_text.module b/custom_text.module
index b8ca777..dd7457b 100644
--- a/custom_text.module
+++ b/custom_text.module
@@ -3,74 +3,43 @@
  * @file Custom Text module file. 
  */
 
-
-/**
- * Implements hook_menu(). 
- */
-function custom_text_menu() {
-  $items = array();
-
-  $items['admin/structure/custom_text'] = array(
-    'title' => 'Custom Text',
-    'description' => 'Edit custom texts used throughout the website.',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('custom_text_admin_form'),
-    'access arguments' => array('change custom text'),
-  );
-
-  return $items;
-}
-
-/**
- * Implements hook_permission(). 
- */
-function custom_text_permission() {
-  $permissions = array();
-
-  $permissions['change custom text'] = array(
-    'title' => t('Change custom text'),
-    'description' => t('Allow user to change custom texts.'),
-  );
-
-  return $permissions;
-}
-
 /**
  * Implements hook_hook_info(). 
  */
 function custom_text_hook_info() {
   $hooks = array();
-
   $hooks['custom_text_group_info'] = array(
     'group' => 'custom_text',
   );
-
   $hooks['custom_text_info'] = array(
     'group' => 'custom_text',
   );
-
   return $hooks;
 }
 
 /**
- * Returns the text.
- *
- * The returned text is already formatted, there is no need to pass it throught
- * check_plain() or check_markup().
+ * Change a text.
  */
-function custom_text_get($identifier, $langcode = NULL) {
+function custom_text_set($identifier, $text, $text_format, $langcode = NULL) {
   if (!$langcode) {
-    global $language;
-    $langcode = $language->language;
+    $language = \Drupal::languageManager()->getCurrentLanguage();
+    $langcode = $language->getId();
   }
 
-  $query = db_select('custom_text', 'ct');
-  $query->condition('identifier', $identifier);
-  $query->condition('language', $langcode);
-  $query->addField('ct', 'text_cache');
+  $record = array(
+    'identifier' => $identifier,
+    'language' => $langcode,
+    'text' => $text,
+    'text_format' => $text_format,
+    'text_cache' => $text_format ? (string) check_markup($text, $text_format, $langcode) : SafeMarkup::checkPlain($text),
+  );
 
-  $text = $query->execute()->fetchField();
-  return $text;
+  db_transaction();
+  return \Drupal::database()->merge('custom_text')
+          ->fields($record)
+          ->key(array('identifier' => $identifier,
+            'language' => $langcode))
+          ->execute();
 }
 
 /**
@@ -91,114 +60,21 @@ function _custom_text_get_all() {
 }
 
 /**
- * Change a text.
+ * Returns the text.
+ *
+ * The returned text is already formatted, there is no need to pass it throught
+ * checkPlain() or check_markup().
  */
-function custom_text_set($identifier, $text, $text_format, $langcode = NULL) {
+function custom_text_get($identifier, $langcode = NULL) {
   if (!$langcode) {
-    global $language;
-    $langcode = $language->language;
-  }
-
-  $record = (object) array(
-    'identifier' => $identifier,
-    'language' => $langcode,
-    'text' => $text,
-    'text_format' => $text_format,
-    'text_cache' => $text_format ? check_markup($text, $text_format, $langcode) : check_plain($text),
-  );
-
-  db_transaction();
-  if (custom_text_get($identifier, $langcode) === FALSE) {
-    // New record, insert
-    return drupal_write_record('custom_text', $record);
-  }
-  else {
-    // Existing record, update
-    return drupal_write_record('custom_text', $record, array('identifier', 'language'));
-  }
-}
-
-/**
- * Form builder for the text admin form. 
- */
-function custom_text_admin_form($form, &$form_state) {
-  $form = array();
-
-  // Get the texts info
-  $texts_group_info = module_invoke_all('custom_text_group_info');
-  $texts_info = module_invoke_all('custom_text_info');
-
-  // If there are no valid identifiers, quit.
-  if (!$texts_info || !$texts_group_info) {
-    $form['error'] = array(
-      '#title' => t('Error'),
-      '#markup' => t('There are no texts defined by any of the modules used by this site, or you do not have permission to edit any of the texts. See <code>custom_text.api.php</code>.'),
-    );
-
-    return $form;
-  }
-
-  $languages = language_list();
-  $texts = _custom_text_get_all();
-
-  $form['texts'] = array(
-    '#type' => 'vertical_tabs',
-    '#title' => t('Custom Texts'),
-  );
-
-  foreach ($texts_group_info as $text_group_identifier => $text_group_element) {
-    $form['texts'][$text_group_identifier] = array(
-      '#type' => 'fieldset',
-    ) + $text_group_element;
-
-    $form['texts'][$text_group_identifier]['passthru'] = array(
-      '#type' => 'vertical_tabs',
-    );
-
-    foreach ($languages as $langcode => $language) {
-      $form['texts'][$text_group_identifier]['passthru'][$langcode] = array(
-        '#type' => 'fieldset',
-        '#title' => $language->native,
-      );
-
-      foreach ($texts_info[$text_group_identifier] as $text_identifier => $text_element) {
-        if (preg_match('/^[\w_-]{1,64}$/', $text_identifier) && !preg_match('/--/', $text_identifier)) {
-          $form['texts'][$text_group_identifier]['passthru'][$langcode]['text--' . $text_identifier . '--' . $langcode] = array(
-            '#default_value' => isset($texts[$text_identifier][$langcode]) ? $texts[$text_identifier][$langcode]['value'] : '',
-            '#format' => isset($texts[$text_identifier][$langcode]) ? $texts[$text_identifier][$langcode]['format'] : NULL,
-          ) + $text_element;
-        }
-      }
-    }
-  }
-
-  $form['submit'] = array(
-    '#type' => 'submit',
-    '#value' => t('Save changes'),
-  );
-
-  return $form;
-}
-
-/**
- * Submit handler for the text admin form.
- */
-function custom_text_admin_form_submit($form, &$form_state) {
-  foreach ($form_state['values'] as $key => $value) {
-    $matches = array();
-    if (preg_match('/^text--([\w_-]+)--(\w+)$/', $key, $matches)) {
-      list(, $identifier, $langcode) = $matches;
-      if (is_array($value)) {
-        $text = $value['value'];
-        $text_format = $value['format'];
-      }
-      else {
-        $text = $value;
-        $text_format = NULL;
-      }
-      custom_text_set($identifier, $text, $text_format, $langcode);
-    }
+    $language = \Drupal::languageManager()->getCurrentLanguage();
+    $langcode = $language->getId();
   }
+  $query = db_select('custom_text', 'ct');
+  $query->condition('identifier', $identifier);
+  $query->condition('language', $langcode);
+  $query->addField('ct', 'text_cache');
 
-  drupal_set_message('Your changes were saved.');
-}
+  $text = $query->execute()->fetchField();
+  return $text;
+}
\ No newline at end of file
diff --git a/custom_text.permissions.yml b/custom_text.permissions.yml
index e69de29..2159e54 100644
--- a/custom_text.permissions.yml
+++ b/custom_text.permissions.yml
@@ -0,0 +1,3 @@
+change custom text:
+  title: 'Change custom text'
+  description: 'Allow user to change custom texts.'
\ No newline at end of file
diff --git a/custom_text.routing.yml b/custom_text.routing.yml
index e69de29..743ed4c 100644
--- a/custom_text.routing.yml
+++ b/custom_text.routing.yml
@@ -0,0 +1,7 @@
+custom_text.config_form:
+  path: '/admin/structure/custom_text'
+  defaults:
+    _form: '\Drupal\custom_text\Form\CustomTextAdminForm'
+    _title: 'Custom Text'
+  requirements:
+    _permission: 'Change custom text'
\ No newline at end of file
diff --git a/src/Form/CustomTextAdminForm.php b/src/Form/CustomTextAdminForm.php
index e69de29..e576efe 100644
--- a/src/Form/CustomTextAdminForm.php
+++ b/src/Form/CustomTextAdminForm.php
@@ -0,0 +1,140 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\custom_text\Form\CustomTextAdminForm.
+ */
+
+namespace Drupal\custom_text\Form;
+
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Form\FormBase;
+use Drupal\Core\Language\LanguageManagerInterface;
+use Drupal\Core\Extension\ModuleHandlerInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+/**
+ * Defines a form to configure identfication settings for this site.
+ */
+class CustomTextAdminForm extends FormBase {
+
+  /**
+   * The language manager.
+   *
+   * @var \Drupal\language\ConfigurableLanguageManagerInterface
+   */
+  protected $languageManager;
+
+  /**
+   * The module handler.
+   *
+   * @var \Drupal\Core\Extension\ModuleHandlerInterface
+   */
+  protected $moduleHandler;
+
+  /**
+   * Constructs a ConfigCustomTextForm.
+   *
+   * @param \Drupal\Core\Language\LanguageManagerInterface
+   *   The language manager.
+   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
+   *   The module handler.
+   */
+  public function __construct(LanguageManagerInterface $language_manager, ModuleHandlerInterface $module_handler) {
+    $this->languageManager = $language_manager;
+    $this->moduleHandler = $module_handler;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container) {
+    return new static(
+        $container->get('language_manager'), $container->get('module_handler')
+    );
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getFormID() {
+    return 'custom_text_admin_form';
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildForm(array $form, FormStateInterface $form_state) {
+    $form = array();
+    // Get the texts info
+    $texts_group_info = $this->moduleHandler->invokeAll('custom_text_group_info');
+    $texts_info = $this->moduleHandler->invokeAll('custom_text_info');
+    // If there are no valid identifiers, quit.
+    if (!$texts_info || !$texts_group_info) {
+      $form['error'] = array(
+        '#title' => t('Error'),
+        '#markup' => t('There are no texts defined by any of the modules used by this site, or you do not have permission to edit any of the texts. See <code>custom_text.api.php</code>.'),
+      );
+      return $form;
+    }
+    $languages = $this->languageManager->getLanguages();
+    $texts = _custom_text_get_all();
+    $form['texts'] = array(
+      '#type' => 'vertical_tabs',
+      '#title' => t('Custom Texts'),
+    );
+
+    foreach ($texts_group_info as $text_group_identifier => $text_group_element) {
+      $form[$text_group_identifier] = array(
+        '#type' => 'details',
+        '#group' => 'texts',
+          ) + $text_group_element;
+
+      foreach ($languages as $langcode => $language) {
+        $form[$text_group_identifier][$langcode] = array(
+          '#type' => 'details',
+          '#title' => $language->getName(),
+          '#group' => 'passthru',
+        );
+
+        foreach ($texts_info[$text_group_identifier] as $text_identifier => $text_element) {
+          if (preg_match('/^[\w_-]{1,64}$/', $text_identifier) && !preg_match('/--/', $text_identifier)) {
+            $form[$text_group_identifier][$langcode]['text--' . $text_identifier . '--' . $langcode] = array(
+              '#default_value' => isset($texts[$text_identifier][$langcode]) ? $texts[$text_identifier][$langcode]['value'] : NULL,
+              '#format' => isset($texts[$text_identifier][$langcode]) ? $texts[$text_identifier][$langcode]['format'] : NULL,
+                ) + $text_element;
+          }
+        }
+      }
+    }
+
+    $form['submit'] = array(
+      '#type' => 'submit',
+      '#value' => t('Save changes'),
+    );
+    return $form;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function submitForm(array &$form, FormStateInterface $form_state) {
+    foreach ($form_state->getUserInput() as $key => $value) {
+      $matches = array();
+      if (preg_match('/^text--([\w_-]+)--(\w+)$/', $key, $matches)) {
+        list(, $identifier, $langcode) = $matches;
+        if (is_array($value)) {
+          $text = $value['value'];
+          $text_format = $value['format'];
+        }
+        else {
+          $text = $value;
+          $text_format = NULL;
+        }
+        custom_text_set($identifier, $text, $text_format, $langcode);
+      }
+    }
+    drupal_set_message('Your changes were saved.');
+  }
+
+}
\ No newline at end of file
