diff --git a/advagg_bundler/src/Form/SettingsForm.php b/advagg_bundler/src/Form/SettingsForm.php
index eb05e52..23edd27 100644
--- a/advagg_bundler/src/Form/SettingsForm.php
+++ b/advagg_bundler/src/Form/SettingsForm.php
@@ -8,6 +8,7 @@
 namespace Drupal\advagg_bundler\Form;
 
 use Drupal\Core\Asset\AssetCollectionOptimizerInterface;
+use Drupal\Core\Cache\Cache;
 use Drupal\Core\Config\ConfigFactoryInterface;
 use Drupal\Core\Form\ConfigFormBase;
 use Drupal\Core\Form\FormStateInterface;
@@ -189,7 +190,7 @@ class SettingsForm extends ConfigFormBase {
     // Clear relevant caches.
     $this->cssCollectionOptimizer->deleteAll();
     $this->jsCollectionOptimizer->deleteAll();
-    \Drupal\Core\Cache\Cache::invalidateTags(['library_info', 'advagg_css', 'advagg_js']);
+    Cache::invalidateTags(['library_info', 'advagg_css', 'advagg_js']);
   }
 
 }
diff --git a/advagg_bundler/src/Tests/BundlerPagesTest.php b/advagg_bundler/src/Tests/BundlerPagesTest.php
index 116f69f..02a2ded 100644
--- a/advagg_bundler/src/Tests/BundlerPagesTest.php
+++ b/advagg_bundler/src/Tests/BundlerPagesTest.php
@@ -7,7 +7,6 @@
 
 namespace Drupal\advagg_bundler\Tests;
 
-use Drupal\Core\Url;
 use Drupal\advagg\Tests\AdminPagesTest;
 
 /**
diff --git a/advagg_cdn/src/Form/SettingsForm.php b/advagg_cdn/src/Form/SettingsForm.php
index ca52781..041c6dd 100644
--- a/advagg_cdn/src/Form/SettingsForm.php
+++ b/advagg_cdn/src/Form/SettingsForm.php
@@ -8,6 +8,7 @@
 namespace Drupal\advagg_cdn\Form;
 
 use Drupal\Core\Asset\AssetCollectionOptimizerInterface;
+use Drupal\Core\Cache\Cache;
 use Drupal\Core\Config\ConfigFactoryInterface;
 use Drupal\Core\Form\ConfigFormBase;
 use Drupal\Core\Form\FormStateInterface;
@@ -192,7 +193,7 @@ class SettingsForm extends ConfigFormBase {
     // Clear relevant caches.
     $this->cssCollectionOptimizer->deleteAll();
     $this->jsCollectionOptimizer->deleteAll();
-    \Drupal\Core\Cache\Cache::invalidateTags(['library_info']);
+    Cache::invalidateTags(['library_info']);
   }
 
 }
diff --git a/advagg_cdn/src/Tests/CdnPagesTest.php b/advagg_cdn/src/Tests/CdnPagesTest.php
index e93b3c1..876febe 100644
--- a/advagg_cdn/src/Tests/CdnPagesTest.php
+++ b/advagg_cdn/src/Tests/CdnPagesTest.php
@@ -7,7 +7,6 @@
 
 namespace Drupal\advagg_cdn\Tests;
 
-use Drupal\Core\Url;
 use Drupal\advagg\Tests\AdminPagesTest;
 
 /**
diff --git a/advagg_css_minify/src/Form/SettingsForm.php b/advagg_css_minify/src/Form/SettingsForm.php
index 733260a..7aa1a0c 100644
--- a/advagg_css_minify/src/Form/SettingsForm.php
+++ b/advagg_css_minify/src/Form/SettingsForm.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\advagg_css_minify\Form;
 
+use Drupal\Component\Render\HtmlEscapedText;
 use Drupal\Core\Asset\AssetCollectionOptimizerInterface;
 use Drupal\Core\Asset\AssetOptimizerInterface;
 use Drupal\Core\Cache\Cache;
@@ -15,7 +16,6 @@ use Drupal\Core\Form\ConfigFormBase;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\State\StateInterface;
 use Drupal\Core\Url;
-use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\Xss;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
@@ -132,7 +132,7 @@ class SettingsForm extends ConfigFormBase {
       if (!isset($form['per_file_settings'][$dir])) {
         $form['per_file_settings'][$dir] = [
           '#type' => 'details',
-          '#title' => SafeMarkup::checkPlain($dir),
+          '#title' => new HtmlEscapedText($dir),
         ];
       }
       $form_api_filename = str_replace(['/', '.'], ['__', '--'], $name);
diff --git a/advagg_css_minify/src/Tests/CssMinifyPagesTest.php b/advagg_css_minify/src/Tests/CssMinifyPagesTest.php
index 798b38c..bd4e2f1 100644
--- a/advagg_css_minify/src/Tests/CssMinifyPagesTest.php
+++ b/advagg_css_minify/src/Tests/CssMinifyPagesTest.php
@@ -7,7 +7,6 @@
 
 namespace Drupal\advagg_css_minify\Tests;
 
-use Drupal\Core\Url;
 use Drupal\advagg\Tests\AdminPagesTest;
 
 /**
diff --git a/advagg_ext_minify/src/Form/SettingsForm.php b/advagg_ext_minify/src/Form/SettingsForm.php
index b773fb2..209a6f2 100644
--- a/advagg_ext_minify/src/Form/SettingsForm.php
+++ b/advagg_ext_minify/src/Form/SettingsForm.php
@@ -8,6 +8,7 @@
 namespace Drupal\advagg_ext_minify\Form;
 
 use Drupal\Core\Asset\AssetCollectionOptimizerInterface;
+use Drupal\Core\Cache\Cache;
 use Drupal\Core\Config\ConfigFactoryInterface;
 use Drupal\Core\Form\ConfigFormBase;
 use Drupal\Core\Form\FormStateInterface;
@@ -162,7 +163,7 @@ class SettingsForm extends ConfigFormBase {
     // Clear relevant caches.
     $this->cssCollectionOptimizer->deleteAll();
     $this->jsCollectionOptimizer->deleteAll();
-    \Drupal\Core\Cache\Cache::invalidateTags(['library_info', 'advagg_css', 'advagg_js']);
+    Cache::invalidateTags(['library_info', 'advagg_css', 'advagg_js']);
   }
 
 }
diff --git a/advagg_ext_minify/src/Tests/ExtMinifyPagesTest.php b/advagg_ext_minify/src/Tests/ExtMinifyPagesTest.php
index 2242b65..996bd22 100644
--- a/advagg_ext_minify/src/Tests/ExtMinifyPagesTest.php
+++ b/advagg_ext_minify/src/Tests/ExtMinifyPagesTest.php
@@ -7,7 +7,6 @@
 
 namespace Drupal\advagg_ext_minify\Tests;
 
-use Drupal\Core\Url;
 use Drupal\advagg\Tests\AdminPagesTest;
 
 /**
diff --git a/advagg_js_minify/src/Asset/JsOptimizer.php b/advagg_js_minify/src/Asset/JsOptimizer.php
index 9a6fba6..257f925 100644
--- a/advagg_js_minify/src/Asset/JsOptimizer.php
+++ b/advagg_js_minify/src/Asset/JsOptimizer.php
@@ -13,6 +13,8 @@ use Drupal\Core\Cache\CacheBackendInterface;
 use Drupal\Core\Config\ConfigFactoryInterface;
 use Drupal\Core\Extension\ModuleHandlerInterface;
 use Drupal\Core\State\StateInterface;
+use JShrink\Minifier;
+use Patchwork\JSqueeze;
 
 /**
  * Optimizes a JavaScript asset.
@@ -364,15 +366,15 @@ class JsOptimizer implements AssetOptimizerInterface {
     ob_start();
     try {
       // JShrink the contents of the aggregated file.
-      $contents = \JShrink\Minifier::minify($contents, ['flaggedComments' => FALSE]);
+      $contents = Minifier::minify($contents, ['flaggedComments' => FALSE]);
 
       // Capture any output from JShrink.
       $error = trim(ob_get_contents());
       if (!empty($error)) {
-        throw new Exception($error);
+        throw new \Exception($error);
       }
     }
-    catch (Exception $e) {
+    catch (\Exception $e) {
       // Log the JShrink exception and rollback to uncompressed content.
       if ($log_errors) {
         \Drupal::logger('advagg_js_minify')->warning($e->getMessage() . '<pre>' . $contents_before . '</pre>', []);
@@ -404,7 +406,7 @@ class JsOptimizer implements AssetOptimizerInterface {
     ob_start();
     try {
       // Minify the contents of the aggregated file.
-      $jz = new \Patchwork\JSqueeze();
+      $jz = new JSqueeze();
       $contents = $jz->squeeze(
         $contents,
         TRUE,
@@ -415,10 +417,10 @@ class JsOptimizer implements AssetOptimizerInterface {
       // Capture any output from JSqueeze.
       $error = trim(ob_get_contents());
       if (!empty($error)) {
-        throw new Exception($error);
+        throw new \Exception($error);
       }
     }
-    catch (Exception $e) {
+    catch (\Exception $e) {
       // Log the JSqueeze exception and rollback to uncompressed content.
       if ($log_errors) {
         \Drupal::logger('advagg_js_minify')->warning('JSqueeze error, skipping file. ' . $e->getMessage() . '<pre>' . $contents_before . '</pre>', []);
diff --git a/advagg_js_minify/src/Form/SettingsForm.php b/advagg_js_minify/src/Form/SettingsForm.php
index a614a1c..6106cd6 100644
--- a/advagg_js_minify/src/Form/SettingsForm.php
+++ b/advagg_js_minify/src/Form/SettingsForm.php
@@ -7,8 +7,11 @@
 
 namespace Drupal\advagg_js_minify\Form;
 
+use Drupal\Component\Render\HtmlEscapedText;
+use Drupal\Component\Utility\Xss;
 use Drupal\Core\Asset\AssetCollectionOptimizerInterface;
 use Drupal\Core\Asset\AssetOptimizerInterface;
+use Drupal\Core\Cache\Cache;
 use Drupal\Core\Config\ConfigFactoryInterface;
 use Drupal\Core\Form\ConfigFormBase;
 use Drupal\Core\Form\FormStateInterface;
@@ -107,7 +110,7 @@ class SettingsForm extends ConfigFormBase {
       '#title' => t('Minification: Select a minifier'),
       '#default_value' => $config->get('minifier'),
       '#options' => $options,
-      '#description' => \Drupal\Component\Utility\Xss::filter($description),
+      '#description' => Xss::filter($description),
     ];
     $form['add_license'] = [
       '#type' => 'checkbox',
@@ -138,7 +141,7 @@ class SettingsForm extends ConfigFormBase {
       if (!isset($form['per_file_settings'][$dir])) {
         $form['per_file_settings'][$dir] = [
           '#type' => 'details',
-          '#title' => \Drupal\Component\Utility\SafeMarkup::checkPlain($dir),
+          '#title' => new HtmlEscapedText($dir),
         ];
       }
       $form_api_filename = str_replace(['/', '.'], ['__', '--'], $name);
@@ -195,7 +198,7 @@ class SettingsForm extends ConfigFormBase {
 
     // Clear Caches.
     $this->jsCollectionOptimizer->deleteAll();
-    \Drupal\Core\Cache\Cache::invalidateTags(['library_info', 'advagg_js']);
+    Cache::invalidateTags(['library_info', 'advagg_js']);
 
     // Save settings.
     $config->set('add_license', $form_state->getValue('add_license'))
diff --git a/advagg_js_minify/src/Tests/JsMinifyPagesTest.php b/advagg_js_minify/src/Tests/JsMinifyPagesTest.php
index 5910138..2ffd3f2 100644
--- a/advagg_js_minify/src/Tests/JsMinifyPagesTest.php
+++ b/advagg_js_minify/src/Tests/JsMinifyPagesTest.php
@@ -7,7 +7,6 @@
 
 namespace Drupal\advagg_js_minify\Tests;
 
-use Drupal\Core\Url;
 use Drupal\advagg\Tests\AdminPagesTest;
 
 /**
diff --git a/advagg_mod/advagg_mod.install b/advagg_mod/advagg_mod.install
index 64716cb..72691ff 100644
--- a/advagg_mod/advagg_mod.install
+++ b/advagg_mod/advagg_mod.install
@@ -5,8 +5,6 @@
  * Handles Advanced Aggregation mod submodule installation and upgrade tasks.
  */
 
-use Drupal\Core\Url;
-
 /**
  * Implements hook_update_N().
  *
diff --git a/advagg_mod/src/Tests/ModifierPagesTest.php b/advagg_mod/src/Tests/ModifierPagesTest.php
index d4b09cd..47377b5 100644
--- a/advagg_mod/src/Tests/ModifierPagesTest.php
+++ b/advagg_mod/src/Tests/ModifierPagesTest.php
@@ -7,8 +7,8 @@
 
 namespace Drupal\advagg_mod\Tests;
 
-use Drupal\Core\Url;
 use Drupal\advagg\Tests\AdminPagesTest;
+use Drupal\Core\Url;
 
 /**
  * Tests that all the AdvAgg Modifier path(s) return valid content.
@@ -31,4 +31,13 @@ class ModifierPagesTest extends AdminPagesTest {
    */
   public $routes = ['advagg_mod.settings'];
 
+  /**
+   * Tests that the main admin path returns correct contents.
+   */
+  public function testLoad() {
+    foreach ($this->routes as $route) {
+      $this->drupalGet(Url::fromRoute($route));
+      $this->assertResponse(200);
+    }
+  }
 }
diff --git a/advagg_validator/src/Form/BaseValidatorForm.php b/advagg_validator/src/Form/BaseValidatorForm.php
index d95c561..d54ad64 100644
--- a/advagg_validator/src/Form/BaseValidatorForm.php
+++ b/advagg_validator/src/Form/BaseValidatorForm.php
@@ -8,8 +8,7 @@
 namespace Drupal\advagg_validator\Form;
 
 use Drupal\advagg\Form\AdvaggFormBase;
-use Drupal\Core\Form\FormStateInterface;
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Render\HtmlEscapedText;
 
 /**
  * Base form for all advagg validator options.
@@ -55,8 +54,8 @@ abstract class BaseValidatorForm extends AdvaggFormBase {
 
           $point = [
             '#type' => 'details',
-            '#title' => SafeMarkup::checkPlain($value),
-            '#description' => '<strong>' . t('Directory:') . ' </strong>' . SafeMarkup::checkPlain(implode('/', $built)),
+            '#title' => new HtmlEscapedText($value),
+            '#description' => '<strong>' . t('Directory:') . ' </strong>' . new HtmlEscapedText(implode('/', $built)),
             '#weight' => 100,
           ];
           if (!isset($point['check_all_levels']) && $value !== '{ROOT}' && count($levels) != $key + 1) {
@@ -130,7 +129,7 @@ abstract class BaseValidatorForm extends AdvaggFormBase {
             ];
           }
           $point[$form_api_filename] = [
-            '#markup' => SafeMarkup::checkPlain($file) . " </br>\n",
+            '#markup' => new HtmlEscapedText($file) . " </br>\n",
           ];
           if (!isset($point['end'])) {
             $point['end'] = [
@@ -178,7 +177,7 @@ abstract class BaseValidatorForm extends AdvaggFormBase {
           ];
           foreach ($v_data['options'] as $option => $value) {
             $output[$filename][$v_name]['options'][] = [
-              '#markup' => SafeMarkup::checkPlain($option) . ': ' . SafeMarkup::checkPlain($value),
+              '#markup' => new HtmlEscapedText($option) . ': ' . new HtmlEscapedText($value),
               '#suffix' => '</br>',
             ];
           }
@@ -189,7 +188,7 @@ abstract class BaseValidatorForm extends AdvaggFormBase {
             foreach ($v_data['errors'] as $error) {
               $output[$filename][$v_name]['errors'][] = [
                 '#prefix' => '<pre>',
-                '#markup' => SafeMarkup::checkPlain(print_r($error, TRUE)),
+                '#markup' => new HtmlEscapedText(print_r($error, TRUE)),
                 '#suffix' => '</pre>',
               ];
             }
@@ -201,7 +200,7 @@ abstract class BaseValidatorForm extends AdvaggFormBase {
             foreach ($v_data['warnings'] as $warning) {
               $output[$filename][$v_name]['warnings'][] = [
                 '#prefix' => '<pre>',
-                '#markup' => SafeMarkup::checkPlain(print_r($warning, TRUE)),
+                '#markup' => new HtmlEscapedText(print_r($warning, TRUE)),
                 '#suffix' => '</pre>',
               ];
             }
diff --git a/advagg_validator/src/Form/CssW3Form.php b/advagg_validator/src/Form/CssW3Form.php
index ebcf078..843ca04 100644
--- a/advagg_validator/src/Form/CssW3Form.php
+++ b/advagg_validator/src/Form/CssW3Form.php
@@ -12,7 +12,6 @@ use Drupal\Core\Config\ConfigFactoryInterface;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\State\StateInterface;
 use Drupal\Component\Utility\Crypt;
-use Drupal\Component\Utility\SafeMarkup;
 use GuzzleHttp\Client;
 use GuzzleHttp\Exception\RequestException;
 use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -97,7 +96,7 @@ class CssW3Form extends BaseValidatorForm {
       '#theme' => 'item_list',
       '#items' => $info,
     ];
-    drupal_set_message(drupal_render($output));
+    drupal_set_message(\Drupal::service('renderer')->render($output));
   }
 
   /**
@@ -135,7 +134,7 @@ class CssW3Form extends BaseValidatorForm {
       '#theme' => 'item_list',
       '#items' => $info,
     ];
-    drupal_set_message(drupal_render($output));
+    drupal_set_message(\Drupal::service('renderer')->render($output));
   }
 
   /**
diff --git a/advagg_validator/src/Tests/ValidatorPagesTest.php b/advagg_validator/src/Tests/ValidatorPagesTest.php
index b81ae21..e146a36 100644
--- a/advagg_validator/src/Tests/ValidatorPagesTest.php
+++ b/advagg_validator/src/Tests/ValidatorPagesTest.php
@@ -7,8 +7,8 @@
 
 namespace Drupal\advagg_validator\Tests;
 
-use Drupal\Core\Url;
 use Drupal\advagg\Tests\AdminPagesTest;
+use Drupal\Core\Url;
 
 /**
  * Tests that all the AdvAgg validator path(s) return valid content.
@@ -34,4 +34,14 @@ class ValidatorPagesTest extends AdminPagesTest {
   // Disabling temporarily due to memory issues while testing.
   // memory usage on validation pages should be fixed.
 
+  /**
+   * Tests that the main admin path returns correct contents.
+   */
+  public function testLoad() {
+    foreach ($this->routes as $route) {
+      $this->drupalGet(Url::fromRoute($route));
+      $this->assertResponse(200);
+    }
+  }
+
 }
diff --git a/src/Ajax/AjaxResponseAttachmentsProcessor.php b/src/Ajax/AjaxResponseAttachmentsProcessor.php
index 1f763e9..39523d2 100644
--- a/src/Ajax/AjaxResponseAttachmentsProcessor.php
+++ b/src/Ajax/AjaxResponseAttachmentsProcessor.php
@@ -12,16 +12,9 @@ use Drupal\Core\Ajax\AddCssCommand;
 use Drupal\Core\Ajax\AppendCommand;
 use Drupal\Core\Ajax\PrependCommand;
 use Drupal\Core\Ajax\SettingsCommand;
-use Drupal\Core\Asset\AssetCollectionRendererInterface;
-use Drupal\Core\Asset\AssetResolverInterface;
 use Drupal\Core\Asset\AttachedAssets;
-use Drupal\Core\Config\ConfigFactoryInterface;
-use Drupal\Core\Extension\ModuleHandlerInterface;
-use Drupal\Core\Render\AttachmentsInterface;
 use Drupal\Core\Render\AttachmentsResponseProcessorInterface;
-use Drupal\Core\Render\RendererInterface;
 use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpFoundation\RequestStack;
 
 /**
  * {@inheritdoc}
diff --git a/src/Asset/JsCollectionGrouper.php b/src/Asset/JsCollectionGrouper.php
index b18dd1e..8fc41ee 100644
--- a/src/Asset/JsCollectionGrouper.php
+++ b/src/Asset/JsCollectionGrouper.php
@@ -8,7 +8,6 @@
 namespace Drupal\advagg\Asset;
 
 use Drupal\Core\Asset\AssetCollectionGrouperInterface;
-use Drupal\Core\Asset\JsCollectionGrouper as CoreJsCollectionGrouper;
 use Drupal\Core\Extension\ModuleHandlerInterface;
 
 /**
diff --git a/src/Form/AdvaggFormBase.php b/src/Form/AdvaggFormBase.php
index 86d50c5..dda1ec3 100644
--- a/src/Form/AdvaggFormBase.php
+++ b/src/Form/AdvaggFormBase.php
@@ -7,15 +7,10 @@
 
 namespace Drupal\advagg\Form;
 
-use Drupal\Component\Utility\SafeMarkup;
-use Drupal\Component\Utility\Unicode;
-use Drupal\Component\Utility\Xss;
 use Drupal\Core\Config\ConfigFactoryInterface;
 use Drupal\Core\Form\ConfigFormBase;
 use Drupal\Core\Form\FormBuilderInterface;
-use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\State\StateInterface;
-use Drupal\Core\Url;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 use Symfony\Component\HttpFoundation\RequestStack;
 
diff --git a/src/Form/InfoForm.php b/src/Form/InfoForm.php
index e74a7a1..06e1f6a 100644
--- a/src/Form/InfoForm.php
+++ b/src/Form/InfoForm.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\advagg\Form;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Render\HtmlEscapedText;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Component\Utility\Xss;
 use Drupal\Core\Config\ConfigFactoryInterface;
@@ -18,7 +18,6 @@ use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\State\StateInterface;
 use Drupal\Core\StringTranslation\Translator\TranslatorInterface;
 use Drupal\Core\Theme\Registry;
-use Drupal\Core\Url;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 use Symfony\Component\HttpFoundation\RequestStack;
 
@@ -201,12 +200,12 @@ class InfoForm extends ConfigFormBase {
     foreach ($module_hooks as $hook => $values) {
       if (empty($values)) {
         $form['modules_implementing_advagg'][$hook] = [
-          '#markup' => '<div><strong>' . SafeMarkup::checkPlain($hook) . ':</strong> 0</div>',
+          '#markup' => '<div><strong>' . new HtmlEscapedText($hook) . ':</strong> 0</div>',
         ];
       }
       else {
         $form['modules_implementing_advagg'][$hook] = [
-          '#markup' => '<div><strong>' . SafeMarkup::checkPlain($hook) . ':</strong> ' . count($values) . $this->formatList($values) . '</div>',
+          '#markup' => '<div><strong>' . new HtmlEscapedText($hook) . ':</strong> ' . count($values) . $this->formatList($values) . '</div>',
         ];
       }
     }
@@ -215,12 +214,12 @@ class InfoForm extends ConfigFormBase {
     foreach ($advagg_hooks as $hook => $values) {
       if (empty($values)) {
         $form['hooks_implemented'][$hook] = [
-          '#markup' => '<div><strong>' . SafeMarkup::checkPlain($hook) . ':</strong> 0</div>',
+          '#markup' => '<div><strong>' . new HtmlEscapedText($hook) . ':</strong> 0</div>',
         ];
       }
       else {
         $form['hooks_implemented'][$hook] = [
-          '#markup' => '<div><strong>' . SafeMarkup::checkPlain($hook) . ':</strong> ' . count($values) . $this->formatList($values) . '</div>',
+          '#markup' => '<div><strong>' . new HtmlEscapedText($hook) . ':</strong> ' . count($values) . $this->formatList($values) . '</div>',
         ];
       }
     }
@@ -303,7 +302,7 @@ class InfoForm extends ConfigFormBase {
    */
   public function getFileInfoSubmit(array &$form, FormStateInterface $form_state) {
     $info = $this->getFileInfo($form_state->getValue('filename'));
-    $output = '<pre>' . SafeMarkup::checkPlain(print_r($info, TRUE)) . '</pre>';
+    $output = '<pre>' . new HtmlEscapedText(print_r($info, TRUE)) . '</pre>';
     if (!$this->isAjax()) {
       drupal_set_message($output);
     }
diff --git a/src/Form/OperationsForm.php b/src/Form/OperationsForm.php
index 83f91fd..43647ba 100644
--- a/src/Form/OperationsForm.php
+++ b/src/Form/OperationsForm.php
@@ -15,7 +15,6 @@ use Drupal\Core\Form\ConfigFormBase;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\PrivateKey;
 use Drupal\Core\State\StateInterface;
-use Drupal\Core\Url;
 use Drupal\Component\Utility\Crypt;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
diff --git a/src/State/State.php b/src/State/State.php
index 5f7b751..85a0509 100644
--- a/src/State/State.php
+++ b/src/State/State.php
@@ -7,7 +7,6 @@
 
 namespace Drupal\advagg\State;
 
-use Drupal\Core\KeyValueStore\KeyValueFactoryInterface;
 use Drupal\Core\State\State as CoreState;
 use Drupal\Core\State\StateInterface;
 
diff --git a/tests/advagg.test b/tests/advagg.test
index e6f212f..0d4824c 100644
--- a/tests/advagg.test
+++ b/tests/advagg.test
@@ -1,4 +1,5 @@
 <?php
+
 // @codingStandardsIgnoreFile
 // @ignore comment_docblock_file:file
 // @ignore style_curly_braces:file
@@ -25,6 +26,8 @@
  * Tests for advagg.module.
  */
 
+use Drupal\Component\Render\FormattableMarkup;
+
 /**
  * Resets static variables related to adding CSS to a page.
  */
@@ -135,7 +138,7 @@ class AdvAggCascadingStylesheetsTestCase extends DrupalWebTestCase {
     // Get the render array.
     $full_css = advagg_get_css();
     // Render the CSS.
-    $styles = drupal_render($full_css);
+    $styles = \Drupal::service('renderer')->render($full_css);
     $this->assertTrue(strpos($styles, $css) > 0, 'Rendered CSS includes the added stylesheet.');
     // Verify that newlines are properly added inside style tags.
     // @FIXME
@@ -164,7 +167,7 @@ class AdvAggCascadingStylesheetsTestCase extends DrupalWebTestCase {
     // Get the render array.
     $full_css = advagg_get_css();
     // Render the CSS.
-    $styles = drupal_render($full_css);
+    $styles = \Drupal::service('renderer')->render($full_css);
     // Stylesheet URL may be the href of a LINK tag or in an @import statement
     // of a STYLE tag.
     $this->assertTrue(strpos($styles, 'href="' . $css) > 0 || strpos($styles, '@import url("' . $css . '")') > 0, 'Rendering an external CSS file.');
@@ -189,7 +192,7 @@ class AdvAggCascadingStylesheetsTestCase extends DrupalWebTestCase {
     // Get the render array.
     $full_css = advagg_get_css();
     // Render the CSS.
-    $styles = drupal_render($full_css);
+    $styles = \Drupal::service('renderer')->render($full_css);
     $this->assertEqual(trim($styles), $css_preprocessed, 'Rendering preprocessed inline CSS adds it to the page.');
 
     //
@@ -231,7 +234,7 @@ class AdvAggCascadingStylesheetsTestCase extends DrupalWebTestCase {
     // Get the render array.
     $full_css = advagg_get_css();
     // Render the CSS.
-    $styles = drupal_render($full_css);
+    $styles = \Drupal::service('renderer')->render($full_css);
     $this->assertTrue(strpos($styles, $css) > 0, 'Rendering non-preprocessed inline CSS adds it to the page.');
 
     //
@@ -285,7 +288,7 @@ class AdvAggCascadingStylesheetsTestCase extends DrupalWebTestCase {
     // Get the render array.
     $full_css = advagg_get_css();
     // Render the CSS.
-    $styles = drupal_render($full_css);
+    $styles = \Drupal::service('renderer')->renderr($full_css);
     // Stylesheet URL may be the href of a LINK tag or in an @import statement
     // of a STYLE tag.
     if (preg_match_all('/(href="|url\(")' . preg_quote($GLOBALS['base_url'] . '/', '/') . '([^?]+)\?/', $styles, $matches)) {
@@ -323,7 +326,7 @@ class AdvAggCascadingStylesheetsTestCase extends DrupalWebTestCase {
     // Get the render array.
     $full_css = advagg_get_css();
     // Render the CSS.
-    $styles = drupal_render($full_css);
+    $styles = \Drupal::service('renderer')->render($full_css);
     $this->assert(strpos($styles, $simpletest . '/tests/system.base.css') !== FALSE, 'The overriding CSS file is output.');
     $this->assert(strpos($styles, $system . '/system.base.css') === FALSE, 'The overridden CSS file is not output.');
     // The reset is needed here until this is fixed
@@ -350,7 +353,7 @@ class AdvAggCascadingStylesheetsTestCase extends DrupalWebTestCase {
     // Get the render array.
     $full_css = advagg_get_css();
     // Render the CSS.
-    $styles = drupal_render($full_css);
+    $styles = \Drupal::service('renderer')->render($full_css);
     // The standard stylesheet should be the only one included.
     $this->assert(strpos($styles, $system . '/system.base.css') !== FALSE, 'The overriding CSS file is output.');
     $this->assert(strpos($styles, $simpletest . '/tests/system.base.css') === FALSE, 'The overridden CSS file is not output.');
@@ -374,7 +377,7 @@ class AdvAggCascadingStylesheetsTestCase extends DrupalWebTestCase {
     // Get the render array.
     $full_css = advagg_get_css();
     // Render the CSS.
-    $styles = drupal_render($full_css);
+    $styles = \Drupal::service('renderer')->render($full_css);
     // Check to see if system.base-rtl.css was also added.
     $this->assert(strpos($styles, $path . '/system.base-rtl.css') !== FALSE, 'CSS is alterable as right to left overrides are added.');
     // Change the language back to left to right.
@@ -576,22 +579,22 @@ class AdvAggCascadingStylesheetsTestCase extends DrupalWebTestCase {
 
       $expected = file_get_contents($file_path . '.unoptimized.css');
       $unoptimized_output = advagg_load_stylesheet($file_path, FALSE);
-      $this->assertEqual($unoptimized_output, $expected, format_string('Unoptimized CSS file has expected contents (@file)', array('@file' => $file)));
+      $this->assertEqual($unoptimized_output, $expected, new FormattableMarkup('Unoptimized CSS file has expected contents (@file)', array('@file' => $file)));
 
       $expected = file_get_contents($file_path . '.optimized.css');
       $expected = advagg_test_remove_sniffer_comments($expected);
       $optimized_output = advagg_load_stylesheet($file_path, TRUE);
-      $this->assertEqual($optimized_output, $expected, format_string('Optimized CSS file has expected contents (@file)', array('@file' => $file)));
+      $this->assertEqual($optimized_output, $expected, new FormattableMarkup('Optimized CSS file has expected contents (@file)', array('@file' => $file)));
 
       // Repeat the tests by accessing the stylesheets by URL.
       $expected = file_get_contents($file_path . '.unoptimized.css');
       $unoptimized_output_url = advagg_load_stylesheet($file_url, FALSE);
-      $this->assertEqual($unoptimized_output_url, $expected, format_string('Unoptimized CSS file (loaded from an URL) has expected contents (@file)', array('@file' => $file)));
+      $this->assertEqual($unoptimized_output_url, $expected, new FormattableMarkup('Unoptimized CSS file (loaded from an URL) has expected contents (@file)', array('@file' => $file)));
 
       $expected = file_get_contents($file_path . '.optimized.css');
       $expected = advagg_test_remove_sniffer_comments($expected);
       $optimized_output_url = advagg_load_stylesheet($file_url, TRUE);
-      $this->assertEqual($optimized_output_url, $expected, format_string('Optimized CSS file (loaded from an URL) has expected contents (@file)', array('@file' => $file)));
+      $this->assertEqual($optimized_output_url, $expected, new FormattableMarkup('Optimized CSS file (loaded from an URL) has expected contents (@file)', array('@file' => $file)));
     }
 
     // File. Tests: charset*.css
@@ -609,12 +612,12 @@ class AdvAggCascadingStylesheetsTestCase extends DrupalWebTestCase {
       $expected = file_get_contents($file_path . '.optimized.css');
       $expected = advagg_test_remove_sniffer_comments($expected);
       $optimized_output = advagg_load_stylesheet($file_path, TRUE);
-      $this->assertEqual($optimized_output, $expected, format_string('Optimized CSS file has expected contents (@file)', array('@file' => $file)));
+      $this->assertEqual($optimized_output, $expected, new FormattableMarkup('Optimized CSS file has expected contents (@file)', array('@file' => $file)));
 
       $expected = file_get_contents($file_path . '.optimized.css');
       $expected = advagg_test_remove_sniffer_comments($expected);
       $optimized_output_url = advagg_load_stylesheet($file_url, TRUE);
-      $this->assertEqual($optimized_output_url, $expected, format_string('Optimized CSS file (loaded from an URL) has expected contents (@file)', array('@file' => $file)));
+      $this->assertEqual($optimized_output_url, $expected, new FormattableMarkup('Optimized CSS file (loaded from an URL) has expected contents (@file)', array('@file' => $file)));
     }
 
     $GLOBALS['conf']['path.convert.absolute_to_relative'] = FALSE;
@@ -679,7 +682,7 @@ class AdvAggCascadingStylesheetsTestCase extends DrupalWebTestCase {
         else {
           $optimized_output = str_replace('http://' . $_SERVER['HTTP_HOST'] . $aggregate_settings['variables']['base_path'] . drupal_get_path('module', 'advagg') . '/', '', $optimized_output);
         }
-        $this->assertEqual($optimized_output, $expected, format_string('Optimized CSS file has expected contents (@file). Setting tested: @name; value before: @before, value after: @after', array(
+        $this->assertEqual($optimized_output, $expected, new FormattableMarkup('Optimized CSS file has expected contents (@file). Setting tested: @name; value before: @before, value after: @after', array(
           '@file' => $file,
           '@name' => $name,
           '@before' => (is_bool($before) || strlen((string) $before) == 0) ? strtoupper(var_export($before, TRUE)) : $before,
@@ -701,7 +704,7 @@ class AdvAggCascadingStylesheetsTestCase extends DrupalWebTestCase {
         else {
           $optimized_output_url = str_replace('http://' . $_SERVER['HTTP_HOST'] . $aggregate_settings['variables']['base_path'] . drupal_get_path('module', 'advagg') . '/', '', $optimized_output_url);
         }
-        $this->assertEqual($optimized_output_url, $expected, format_string('Optimized CSS file (loaded from an URL) has expected contents (@file). Setting tested: @name; value before: @before, value after: @after', array(
+        $this->assertEqual($optimized_output_url, $expected, new FormattableMarkup('Optimized CSS file (loaded from an URL) has expected contents (@file). Setting tested: @name; value before: @before, value after: @after', array(
           '@file' => $file,
           '@name' => $name,
           '@before' => (is_bool($before) || strlen((string) $before) == 0) ? strtoupper(var_export($before, TRUE)) : $before,
@@ -822,7 +825,7 @@ class AdvAggJavaScriptTestCase extends DrupalWebTestCase {
 // variable_set('javascript_always_use_jquery', FALSE);
 
     $render_array = advagg_get_js();
-    $javascript = drupal_render($render_array);
+    $javascript = \Drupal::service('renderer')->render($render_array);
     $this->drupalGet('');
     $this->assertNoRaw('misc/jquery.js', 'When "javascript_always_use_jquery" is FALSE: The front page of the site does not include jquery.js.');
     $this->assertNoRaw('misc/drupal.js', 'When "javascript_always_use_jquery" is FALSE: The front page of the site does not include drupal.js.');
@@ -849,7 +852,7 @@ class AdvAggJavaScriptTestCase extends DrupalWebTestCase {
 // drupal_add_js(array('testJavaScriptSetting' => 'test'), 'setting');
 
     $render_array = advagg_get_js();
-    $javascript = drupal_render($render_array);
+    $javascript = \Drupal::service('renderer')->render($render_array);
     $this->assertTrue(strpos($javascript, 'misc/jquery.js') !== FALSE, 'Default behavior: The JavaScript returned by drupal_get_js() when only settings have been added includes jquery.js.');
     $this->assertTrue(strpos($javascript, 'misc/drupal.js') !== FALSE, 'Default behavior: The JavaScript returned by drupal_get_js() when only settings have been added includes drupal.js.');
     $this->assertTrue(strpos($javascript, 'Drupal.settings') !== FALSE, 'Default behavior: The JavaScript returned by drupal_get_js() when only settings have been added includes Drupal.settings.');
@@ -879,7 +882,7 @@ class AdvAggJavaScriptTestCase extends DrupalWebTestCase {
 // drupal_add_js(array('testJavaScriptSetting' => 'test'), 'setting');
 
     $render_array = advagg_get_js();
-    $javascript = drupal_render($render_array);
+    $javascript = \Drupal::service('renderer')->render($render_array);
     $this->assertTrue(strpos($javascript, 'misc/jquery.js') === FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when only settings have been added does not include jquery.js.');
     $this->assertTrue(strpos($javascript, 'misc/drupal.js') === FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when only settings have been added does not include drupal.js.');
     $this->assertTrue(strpos($javascript, 'Drupal.settings') === FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when only settings have been added does not include Drupal.settings.');
@@ -906,7 +909,7 @@ class AdvAggJavaScriptTestCase extends DrupalWebTestCase {
 // drupal_add_js('misc/collapse.js');
 
     $render_array = advagg_get_js();
-    $javascript = drupal_render($render_array);
+    $javascript = \Drupal::service('renderer')->render($render_array);
     $this->assertTrue(strpos($javascript, 'misc/jquery.js') !== FALSE, 'Default behavior: The JavaScript returned by drupal_get_js() when a custom JavaScript file has been added includes jquery.js.');
     $this->assertTrue(strpos($javascript, 'misc/drupal.js') !== FALSE, 'Default behavior: The JavaScript returned by drupal_get_js() when a custom JavaScript file has been added includes drupal.js.');
     $this->assertTrue(strpos($javascript, 'Drupal.settings') !== FALSE, 'Default behavior: The JavaScript returned by drupal_get_js() when a custom JavaScript file has been added includes Drupal.settings.');
@@ -935,7 +938,7 @@ class AdvAggJavaScriptTestCase extends DrupalWebTestCase {
 // drupal_add_js('misc/collapse.js');
 
     $render_array = advagg_get_js();
-    $javascript = drupal_render($render_array);
+    $javascript = \Drupal::service('renderer')->render($render_array);
     $this->assertTrue(strpos($javascript, 'misc/jquery.js') !== FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when a custom JavaScript file has been added includes jquery.js.');
     $this->assertTrue(strpos($javascript, 'misc/drupal.js') !== FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when a custom JavaScript file has been added includes drupal.js.');
     $this->assertTrue(strpos($javascript, 'Drupal.settings') !== FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when a custom JavaScript file has been added includes Drupal.settings.');
@@ -963,7 +966,7 @@ class AdvAggJavaScriptTestCase extends DrupalWebTestCase {
 // drupal_add_js('misc/collapse.js', array('requires_jquery' => FALSE));
 
     $render_array = advagg_get_js();
-    $javascript = drupal_render($render_array);
+    $javascript = \Drupal::service('renderer')->render($render_array);
     $this->assertTrue(strpos($javascript, 'misc/jquery.js') !== FALSE, 'Default behavior: The JavaScript returned by drupal_get_js() when a custom JavaScript file that does not require jQuery has been added includes jquery.js.');
     $this->assertTrue(strpos($javascript, 'misc/drupal.js') !== FALSE, 'Default behavior: The JavaScript returned by drupal_get_js() when a custom JavaScript file that does not require jQuery has been added includes drupal.js.');
     $this->assertTrue(strpos($javascript, 'Drupal.settings') !== FALSE, 'Default behavior: The JavaScript returned by drupal_get_js() when a custom JavaScript file that does not require jQuery has been added includes Drupal.settings.');
@@ -992,7 +995,7 @@ class AdvAggJavaScriptTestCase extends DrupalWebTestCase {
 // drupal_add_js('misc/collapse.js', array('requires_jquery' => FALSE));
 
     $render_array = advagg_get_js();
-    $javascript = drupal_render($render_array);
+    $javascript = \Drupal::service('renderer')->render($render_array);
     $this->assertTrue(strpos($javascript, 'misc/jquery.js') === FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when a custom JavaScript file that does not require jQuery has been added does not include jquery.js.');
     $this->assertTrue(strpos($javascript, 'misc/drupal.js') === FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when a custom JavaScript file that does not require jQuery has been added does not include drupal.js.');
     $this->assertTrue(strpos($javascript, 'Drupal.settings') === FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when a custom JavaScript file that does not require jQuery has been added does not include Drupal.settings.');
@@ -1036,7 +1039,7 @@ class AdvAggJavaScriptTestCase extends DrupalWebTestCase {
 // drupal_add_js('misc/ajax.js');
 
     $render_array = advagg_get_js();
-    $javascript = drupal_render($render_array);
+    $javascript = \Drupal::service('renderer')->render($render_array);
     $this->assertTrue(strpos($javascript, 'misc/jquery.js') !== FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when at least one custom JavaScript file that requires jQuery has been added includes jquery.js.');
     $this->assertTrue(strpos($javascript, 'misc/drupal.js') !== FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when at least one custom JavaScript file that requires jQuery has been added includes drupal.js.');
     $this->assertTrue(strpos($javascript, 'Drupal.settings') !== FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when at least one custom JavaScript file that requires jQuery has been added includes Drupal.settings.');
@@ -1312,7 +1315,7 @@ class AdvAggJavaScriptTestCase extends DrupalWebTestCase {
     );
     // Retrieve the rendered JavaScript and test against the regex.
     $render_array = advagg_get_js('footer');
-    $js = drupal_render($render_array);
+    $js = \Drupal::service('renderer')->render($render_array);
     $matches = array();
     if (preg_match_all('/Weight\s([-0-9]+\s[#0-9]+)/', $js, $matches)) {
       $result = $matches[1];
@@ -1405,7 +1408,7 @@ class AdvAggJavaScriptTestCase extends DrupalWebTestCase {
 // drupal_add_js(array('commonTestArray' => array('key' => 'commonTestNewValue')), 'setting');
 
     $render_array = advagg_get_js('header');
-    $javascript = drupal_render($render_array);
+    $javascript = \Drupal::service('renderer')->render($render_array);
     $this->assertTrue(strpos($javascript, 'basePath') > 0, 'Rendered JavaScript header returns basePath setting.');
     $this->assertTrue(strpos($javascript, 'misc/jquery.js') > 0, 'Rendered JavaScript header includes jQuery.');
     $this->assertTrue(strpos($javascript, 'pathPrefix') > 0, 'Rendered JavaScript header returns pathPrefix setting.');
@@ -1438,7 +1441,7 @@ class AdvAggJavaScriptTestCase extends DrupalWebTestCase {
 // drupal_add_js($external, 'external');
 
     $render_array = advagg_get_js();
-    $javascript = drupal_render($render_array);
+    $javascript = \Drupal::service('renderer')->render($render_array);
     // Local files have a base_path() prefix, external files should not.
     $this->assertTrue(strpos($javascript, 'src="' . $external) > 0, 'Rendering an external JavaScript file.');
 
@@ -1456,7 +1459,7 @@ class AdvAggJavaScriptTestCase extends DrupalWebTestCase {
 // drupal_add_js($inline, array('type' => 'inline', 'scope' => 'footer'));
 
     $render_array = advagg_get_js('footer');
-    $javascript = drupal_render($render_array);
+    $javascript = \Drupal::service('renderer')->render($render_array);
     $this->assertTrue(strpos($javascript, $inline) > 0, 'Rendered JavaScript footer returns the inline code.');
 
     //
@@ -1487,7 +1490,7 @@ class AdvAggJavaScriptTestCase extends DrupalWebTestCase {
 //     ));
 
     $render_array = advagg_get_js();
-    $javascript = drupal_render($render_array);
+    $javascript = \Drupal::service('renderer')->render($render_array);
     $this->assertTrue(strpos($javascript, 'misc/collapse.js') < strpos($javascript, 'misc/jquery.js'), 'Rendering a JavaScript file above jQuery.');
 
     //
@@ -1517,7 +1520,7 @@ class AdvAggJavaScriptTestCase extends DrupalWebTestCase {
     // tableselect.js. See simpletest_js_alter() to see where this alteration
     // takes place.
     $render_array = advagg_get_js();
-    $javascript = drupal_render($render_array);
+    $javascript = \Drupal::service('renderer')->render($render_array);
     $this->assertTrue(strpos($javascript, 'simpletest.js') < strpos($javascript, 'misc/tableselect.js'), 'Altering JavaScript weight through the alter hook.');
 
     //
@@ -1534,9 +1537,9 @@ class AdvAggJavaScriptTestCase extends DrupalWebTestCase {
 
     $this->assertTrue($result !== FALSE, 'Library was added without errors.');
     $render_array = advagg_get_js();
-    $scripts = drupal_render($render_array);
+    $scripts = \Drupal::service('renderer')->render($render_array);
     $render_array = advagg_get_css();
-    $styles = drupal_render($render_array);
+    $styles = \Drupal::service('renderer')->render($render_array);
     $this->assertTrue(strpos($scripts, 'misc/farbtastic/farbtastic.js'), 'JavaScript of library was added to the page.');
     $this->assertTrue(strpos($styles, 'misc/farbtastic/farbtastic.css'), 'Stylesheet of library was added to the page.');
 
@@ -1557,7 +1560,7 @@ class AdvAggJavaScriptTestCase extends DrupalWebTestCase {
 // drupal_add_library('system', 'farbtastic');
 
     $render_array = advagg_get_js();
-    $scripts = drupal_render($render_array);
+    $scripts = \Drupal::service('renderer')->render($render_array);
     $this->assertTrue(strpos($scripts, 'misc/jquery.form.js'), 'Altered library dependencies are added to the page.');
 
     //
@@ -1577,7 +1580,7 @@ class AdvAggJavaScriptTestCase extends DrupalWebTestCase {
 
     $this->assertFalse($result, 'Unknown library returned FALSE.');
     $render_array = advagg_get_js();
-    $scripts = drupal_render($render_array);
+    $scripts = \Drupal::service('renderer')->render($render_array);
     $this->assertTrue(strpos($scripts, 'unknown') === FALSE, 'Unknown library was not added to the page.');
 
     //
@@ -1585,9 +1588,9 @@ class AdvAggJavaScriptTestCase extends DrupalWebTestCase {
     // property.
     advagg_test_reset_statics();
     $element['#attached']['library'][] = array('system', 'farbtastic');
-    drupal_render($element);
+    \Drupal::service('renderer')->render($element);
     $render_array = advagg_get_js();
-    $scripts = drupal_render($render_array);
+    $scripts = \Drupal::service('renderer')->render($render_array);
     $this->assertTrue(strpos($scripts, 'misc/farbtastic/farbtastic.js'), 'The attached_library property adds the additional libraries.');
 
     //
@@ -1619,9 +1622,9 @@ class AdvAggJavaScriptTestCase extends DrupalWebTestCase {
       '#markup' => 'Subchild',
     );
     // Render the element and verify the presence of #attached JavaScript.
-    drupal_render($element);
+    \Drupal::service('renderer')->render($element);
     $render_array = advagg_get_js();
-    $scripts = drupal_render($render_array);
+    $scripts = \Drupal::service('renderer')->render($render_array);
     $this->assertTrue(strpos($scripts, $parent_js), 'The element #attached JavaScript was included.');
     $this->assertTrue(strpos($scripts, $child_js), 'The child #attached JavaScript was included.');
     $this->assertTrue(strpos($scripts, $subchild_js), 'The subchild #attached JavaScript was included.');
@@ -1630,7 +1633,7 @@ class AdvAggJavaScriptTestCase extends DrupalWebTestCase {
     advagg_test_reset_statics();
     $this->assertTrue(drupal_render_cache_get($element), 'The element was retrieved from cache.');
     $render_array = advagg_get_js();
-    $scripts = drupal_render($render_array);
+    $scripts = \Drupal::service('renderer')->render($render_array);
     $this->assertTrue(strpos($scripts, $parent_js), 'The element #attached JavaScript was included when loading from cache.');
     $this->assertTrue(strpos($scripts, $child_js), 'The child #attached JavaScript was included when loading from cache.');
     $this->assertTrue(strpos($scripts, $subchild_js), 'The subchild #attached JavaScript was included when loading from cache.');
@@ -1777,9 +1780,9 @@ class AdvAggThemeTestCase extends AJAXTestCase {
         'browsers' => array('IE' => TRUE, '!IE' => TRUE),
       ),
     ), TRUE);
-    $expected_css_html = drupal_render($expected_css_render_array);
+    $expected_css_html = \Drupal::service('renderer')->render($expected_css_render_array);
     $expected_js_render_array = advagg_get_js('header', array($expected['js'] => drupal_js_defaults($expected['js'])), TRUE);
-    $expected_js_html = drupal_render($expected_js_render_array);
+    $expected_js_html = \Drupal::service('renderer')->render($expected_js_render_array);
     // Get the base page.
     $this->drupalGet('ajax_forms_test_lazy_load_form');
     $original_settings = $this->drupalGetSettings();
