diff --git a/backup_migrate.module b/backup_migrate.module
index 6ba4296..ccacece 100644
--- a/backup_migrate.module
+++ b/backup_migrate.module
@@ -43,10 +43,10 @@ function backup_migrate_perform_backup($source_id, $destination_id, $config = []
 
     // Run the backup.
     $bam->backup($source_id, $destination_id);
-    drupal_set_message(t('Backup Complete.'));
+    \Drupal::messenger()->addMessage(t('Backup Complete.'));
   }
   catch (Exception $e) {
-    drupal_set_message($e->getMessage(), 'error');
+    \Drupal::messenger()->addMessage($e->getMessage(), 'error');
   }
 }
 
@@ -66,10 +66,10 @@ function backup_migrate_perform_restore($source_id, $destination_id, $file_id =
 
     // Run the backup.
     $bam->restore($source_id, $destination_id, $file_id);
-    drupal_set_message(t('Restore Complete.'));
+    \Drupal::messenger()->addMessage(t('Restore Complete.'));
   }
   catch (Exception $e) {
-    drupal_set_message($e->getMessage(), 'error');
+    \Drupal::messenger()->addMessage($e->getMessage(), 'error');
     return;
   }
 }
diff --git a/lib/backup_migrate_core/src/Destination/DirectoryDestination.php b/lib/backup_migrate_core/src/Destination/DirectoryDestination.php
index 5e4c940..db0e66b 100644
--- a/lib/backup_migrate_core/src/Destination/DirectoryDestination.php
+++ b/lib/backup_migrate_core/src/Destination/DirectoryDestination.php
@@ -243,13 +243,13 @@ class DirectoryDestination extends DestinationBase implements ListableDestinatio
     // Read the list of files from the directory.
     $dir = $this->confGet('directory');
 
-    /** @var \Drupal\Core\File\FileSystemInterface $fileSystem */
-    $fileSystem = \Drupal::service('file_system');
-    $scheme = $fileSystem->uriScheme($dir);
+    /** @var \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface $stream_wrapper_manager */
+    $stream_wrapper_manager = \Drupal::service('stream_wrapper_manager');
+    $scheme = $stream_wrapper_manager->isValidScheme($dir);
 
     // Ensure the stream is configured.
-    if (!$fileSystem->validScheme($scheme)) {
-      drupal_set_message(t('Your @scheme stream is not configured.', [
+    if (!$stream_wrapper_manager->isValidScheme($scheme)) {
+      \Drupal::messenger()->addMessage(t('Your @scheme stream is not configured.', [
         '@scheme' => $scheme . '://'
       ]), 'warning');
       return $files;
diff --git a/lib/backup_migrate_core/src/Filter/CompressionFilter.php b/lib/backup_migrate_core/src/Filter/CompressionFilter.php
index 679e6c5..7c7813b 100644
--- a/lib/backup_migrate_core/src/Filter/CompressionFilter.php
+++ b/lib/backup_migrate_core/src/Filter/CompressionFilter.php
@@ -209,7 +209,7 @@ class CompressionFilter extends PluginBase implements FileProcessorInterface {
         gzclose($fp_out);
 
         // Get the compressed filesize and set it.
-        $fileszc = filesize(drupal_realpath($to->realpath()));
+        $fileszc = filesize(\Drupal::service('file_system')->realpath($to->realpath()));
         $to->setMeta('filesize', $fileszc);
       }
     }
@@ -262,7 +262,7 @@ class CompressionFilter extends PluginBase implements FileProcessorInterface {
         bzclose($fp_out);
 
         // Get the compressed filesize and set it.
-        $fileszc = filesize(drupal_realpath($to->realpath()));
+        $fileszc = filesize(\Drupal::service('file_system')->realpath($to->realpath()));
         $to->setMeta('filesize', $fileszc);
       }
     }
@@ -309,14 +309,14 @@ class CompressionFilter extends PluginBase implements FileProcessorInterface {
 
     if (class_exists('ZipArchive')) {
       $zip = new \ZipArchive();
-      $res = $zip->open(drupal_realpath($to->realpath()), constant("ZipArchive::CREATE"));
+      $res = $zip->open(\Drupal::service('file_system')->realpath($to->realpath()), constant("ZipArchive::CREATE"));
       if ($res === TRUE) {
-        $zip->addFile(drupal_realpath($from->realpath()), $from->getFullName());
+        $zip->addFile(\Drupal::service('file_system')->realpath($from->realpath()), $from->getFullName());
       }
       $success = $zip->close();
     }
     // Get the compressed filesize and set it.
-    $fileszc = filesize(drupal_realpath($to->realpath()));
+    $fileszc = filesize(\Drupal::service('file_system')->realpath($to->realpath()));
     $to->setMeta('filesize', $fileszc);
 
     return $success;
@@ -334,7 +334,7 @@ class CompressionFilter extends PluginBase implements FileProcessorInterface {
     $success = FALSE;
     if (class_exists('ZipArchive')) {
       $zip = new \ZipArchive();
-      if ($zip->open(drupal_realpath($from->realpath()))) {
+      if ($zip->open(\Drupal::service('file_system')->realpath($from->realpath()))) {
         $filename = ($zip->getNameIndex(0));
         if ($fp_in = $zip->getStream($filename)) {
           while (!feof($fp_in)) {
diff --git a/src/Controller/BackupController.php b/src/Controller/BackupController.php
index 5d4de65..51f8875 100644
--- a/src/Controller/BackupController.php
+++ b/src/Controller/BackupController.php
@@ -8,6 +8,7 @@ use BackupMigrate\Drupal\Destination\DrupalBrowserDownloadDestination;
 use Drupal\backup_migrate\Entity\Destination;
 use Drupal\Core\Controller\ControllerBase;
 use Drupal\Core\Url;
+use Drupal\Core\Utility\TableSort;
 
 /**
  * Class BackupController.
@@ -115,8 +116,8 @@ class BackupController extends ControllerBase {
       ],
     ];
 
-    $order = tablesort_get_order($header);
-    $sort = tablesort_get_sort($header);
+    $order = TableSort::getOrder($header, \Drupal::request());
+    $sort = TableSort::getSort($header, \Drupal::request());
     $php_sort = $sort == 'desc' ? SORT_DESC : SORT_ASC;
 
     $backups = $destination->queryFiles([], $order['sql'], $php_sort, $count);
diff --git a/src/Controller/ScheduleListBuilder.php b/src/Controller/ScheduleListBuilder.php
index ab84e98..c1814ee 100644
--- a/src/Controller/ScheduleListBuilder.php
+++ b/src/Controller/ScheduleListBuilder.php
@@ -77,7 +77,7 @@ class ScheduleListBuilder extends ConfigEntityListBuilder {
   public function submitForm(array &$form, FormStateInterface $form_state) {
     parent::submitForm($form, $form_state);
 
-    drupal_set_message(t('The schedule settings have been updated.'));
+    \Drupal::messenger()->addMessage(t('The schedule settings have been updated.'));
   }
 
 }
diff --git a/src/Destination/DrupalDirectoryDestination.php b/src/Destination/DrupalDirectoryDestination.php
index f95566e..3487a7d 100644
--- a/src/Destination/DrupalDirectoryDestination.php
+++ b/src/Destination/DrupalDirectoryDestination.php
@@ -5,9 +5,9 @@ namespace BackupMigrate\Drupal\Destination;
 use BackupMigrate\Core\Destination\DirectoryDestination;
 use BackupMigrate\Core\Exception\BackupMigrateException;
 use BackupMigrate\Core\File\BackupFileReadableInterface;
-use Drupal\Core\File\FileSystem;
+use Drupal\Core\File\Exception\FileException;
+use Drupal\Core\File\FileSystemInterface;
 use Drupal\Core\StreamWrapper\PrivateStream;
-use BackupMigrate\Core\File\ReadableStreamBackupFile;
 
 /**
  * Class DrupalDirectoryDestination.
@@ -28,8 +28,12 @@ class DrupalDirectoryDestination extends DirectoryDestination {
     // Check if the directory exists.
     $this->checkDirectory();
 
-    // @TODO Decide what the appropriate file_exists strategy should be.
-    file_unmanaged_move($file->realpath(), $this->_idToPath($file->getFullName()), FILE_EXISTS_REPLACE);
+    try {
+      \Drupal::service('file_system')->move($file->realpath(), $this->_idToPath($file->getFullName()), FileSystemInterface::EXISTS_REPLACE);
+    }
+    catch (FileException $e) {
+      return FALSE;
+    }
   }
 
 
@@ -53,7 +57,7 @@ class DrupalDirectoryDestination extends DirectoryDestination {
           ['%dir' => $dir]
         );
       }
-      if (!file_prepare_directory($dir, FILE_CREATE_DIRECTORY && FILE_MODIFY_PERMISSIONS)) {
+      if (!\Drupal::service('file_system')->prepareDirectory($dir, FileSystemInterface::CREATE_DIRECTORY && FileSystemInterface::MODIFY_PERMISSIONS)) {
         throw new BackupMigrateException(
           "The backup file could not be saved to '%dir' because the directory could not be created or cannot be written to. Please make sure your private files directory is writable by the web server.",
           ['%dir' => $dir]
diff --git a/src/EntityPlugins/WrapperPluginInterface.php b/src/EntityPlugins/WrapperPluginInterface.php
index 994f069..e6fc947 100644
--- a/src/EntityPlugins/WrapperPluginInterface.php
+++ b/src/EntityPlugins/WrapperPluginInterface.php
@@ -3,7 +3,8 @@
 namespace BackupMigrate\Drupal\EntityPlugins;
 
 use BackupMigrate\Core\Main\BackupMigrateInterface;
-use Drupal\Component\Plugin\ConfigurablePluginInterface;
+use Drupal\Component\Plugin\ConfigurableInterface;
+use Drupal\Component\Plugin\DependentPluginInterface;
 
 /**
  * An interface for a plugin which wraps a Backup and Migrate plugin.
@@ -12,7 +13,7 @@ use Drupal\Component\Plugin\ConfigurablePluginInterface;
  *
  * @package BackupMigrate\Drupal\EntityPlugins
  */
-interface WrapperPluginInterface extends ConfigurablePluginInterface {
+interface WrapperPluginInterface extends ConfigurableInterface, DependentPluginInterface {
 
   /**
    * Alter the backup and migrate object to add the source and required services.
diff --git a/src/Environment/DrupalSetMessageLogger.php b/src/Environment/DrupalSetMessageLogger.php
index e732eef..a4ded4a 100644
--- a/src/Environment/DrupalSetMessageLogger.php
+++ b/src/Environment/DrupalSetMessageLogger.php
@@ -45,7 +45,7 @@ class DrupalSetMessageLogger extends AbstractLogger {
     }
 
     // @TODO: Handle translations properly.
-    drupal_set_message($message, $type, FALSE);
+    \Drupal::messenger()->addMessage($message, $type, FALSE);
   }
 
 }
diff --git a/src/Filter/DrupalEncrypt.php b/src/Filter/DrupalEncrypt.php
index 10f0979..4c5b25e 100644
--- a/src/Filter/DrupalEncrypt.php
+++ b/src/Filter/DrupalEncrypt.php
@@ -47,7 +47,7 @@ class DrupalEncrypt extends PluginBase implements FileProcessorInterface {
         ];
       }
       else {
-        drupal_set_message($this->t('Please install the Defuse PHP-encryption library via Composer to be able to encrypt backup files.'), 'warning');
+        \Drupal::messenger()->addMessage($this->t('Please install the Defuse PHP-encryption library via Composer to be able to encrypt backup files.'), 'warning');
 
       }
     }
@@ -68,13 +68,13 @@ class DrupalEncrypt extends PluginBase implements FileProcessorInterface {
 
   protected function _encryptFile (BackupFileReadableInterface $from, BackupFileWritableInterface $to) {
 
-    $path = drupal_realpath($from->realpath());
-    $out_path = drupal_realpath($to->realpath());
+    $path = \Drupal::service('file_system')->realpath($from->realpath());
+    $out_path = \Drupal::service('file_system')->realpath($to->realpath());
 
     try {
 
       CryptoFile::encryptFileWithPassword($path, $out_path, $this->confGet('encrypt_password'));
-      $fileszc = filesize(drupal_realpath($to->realpath()));
+      $fileszc = filesize(\Drupal::service('file_system')->realpath($to->realpath()));
       $to->setMeta('filesize', $fileszc);
       return TRUE;
 
@@ -89,8 +89,8 @@ class DrupalEncrypt extends PluginBase implements FileProcessorInterface {
 
   protected function _decryptFile (BackupFileReadableInterface $from, BackupFileWritableInterface $to) {
 
-    $path = drupal_realpath($from->realpath());
-    $out_path = drupal_realpath($to->realpath());
+    $path = \Drupal::service('file_system')->realpath($from->realpath());
+    $out_path = \Drupal::service('file_system')->realpath($to->realpath());
 
     try {
 
diff --git a/src/Form/BackupMigrateRestoreForm.php b/src/Form/BackupMigrateRestoreForm.php
index 10cf25b..391b194 100644
--- a/src/Form/BackupMigrateRestoreForm.php
+++ b/src/Form/BackupMigrateRestoreForm.php
@@ -3,6 +3,7 @@
 namespace Drupal\backup_migrate\Form;
 
 use BackupMigrate\Drupal\Config\DrupalConfigHelper;
+use Drupal\Component\Utility\Environment;
 use Drupal\Core\Form\FormBase;
 use Drupal\Core\Form\FormStateInterface;
 
@@ -32,7 +33,7 @@ class BackupMigrateRestoreForm extends FormBase {
       '#description' => $this->t("Upload a backup file created by Backup
       and Migrate. For other database or file backups please use another
       tool for import. Max file size: %size",
-       ["%size" => format_size(file_upload_max_size())]
+       ["%size" => format_size(Environment::getUploadMaxSize())]
       ),
     ];
 
diff --git a/src/Form/EntityDeleteForm.php b/src/Form/EntityDeleteForm.php
index caef545..efe0112 100644
--- a/src/Form/EntityDeleteForm.php
+++ b/src/Form/EntityDeleteForm.php
@@ -40,7 +40,7 @@ class EntityDeleteForm extends EntityConfirmFormBase {
   public function submitForm(array &$form, FormStateInterface $form_state) {
     $this->entity->delete();
 
-    drupal_set_message(
+    \Drupal::messenger()->addMessage(
       $this->t('Deleted @label.', ['@label' => $this->entity->label()])
     );
 
diff --git a/src/Form/ScheduleDeleteForm.php b/src/Form/ScheduleDeleteForm.php
index 59bb4e6..a0b2746 100644
--- a/src/Form/ScheduleDeleteForm.php
+++ b/src/Form/ScheduleDeleteForm.php
@@ -38,7 +38,7 @@ class ScheduleDeleteForm extends EntityConfirmFormBase {
   public function submitForm(array &$form, FormStateInterface $form_state) {
     $this->entity->delete();
 
-    drupal_set_message(
+    \Drupal::messenger()->addMessage(
       $this->t('content @type: deleted @label.',
         [
           '@type' => $this->entity->bundle(),
diff --git a/src/Form/ScheduleForm.php b/src/Form/ScheduleForm.php
index d449912..a7d3909 100644
--- a/src/Form/ScheduleForm.php
+++ b/src/Form/ScheduleForm.php
@@ -132,13 +132,13 @@ class ScheduleForm extends EntityForm {
 
     switch ($status) {
       case SAVED_NEW:
-        drupal_set_message($this->t('Created the %label Schedule.', [
+        \Drupal::messenger()->addMessage($this->t('Created the %label Schedule.', [
           '%label' => $backup_migrate_schedule->label(),
         ]));
         break;
 
       default:
-        drupal_set_message($this->t('Saved the %label Schedule.', [
+        \Drupal::messenger()->addMessage($this->t('Saved the %label Schedule.', [
           '%label' => $backup_migrate_schedule->label(),
         ]));
     }
diff --git a/src/Form/SettingsProfileDeleteForm.php b/src/Form/SettingsProfileDeleteForm.php
index c9aadd0..12163e4 100644
--- a/src/Form/SettingsProfileDeleteForm.php
+++ b/src/Form/SettingsProfileDeleteForm.php
@@ -38,7 +38,7 @@ class SettingsProfileDeleteForm extends EntityConfirmFormBase {
   public function submitForm(array &$form, FormStateInterface $form_state) {
     $this->entity->delete();
 
-    drupal_set_message(
+    \Drupal::messenger()->addMessage(
       $this->t('content @type: deleted @label.',
         [
           '@type' => $this->entity->bundle(),
diff --git a/src/Form/SettingsProfileForm.php b/src/Form/SettingsProfileForm.php
index a27b2fe..ba4cd3f 100644
--- a/src/Form/SettingsProfileForm.php
+++ b/src/Form/SettingsProfileForm.php
@@ -54,13 +54,13 @@ class SettingsProfileForm extends EntityForm {
 
     switch ($status) {
       case SAVED_NEW:
-        drupal_set_message($this->t('Created the %label Settings Profile.', [
+        \Drupal::messenger()->addMessage($this->t('Created the %label Settings Profile.', [
           '%label' => $backup_migrate_settings->label(),
         ]));
         break;
 
       default:
-        drupal_set_message($this->t('Saved the %label Settings Profile.', [
+        \Drupal::messenger()->addMessage($this->t('Saved the %label Settings Profile.', [
           '%label' => $backup_migrate_settings->label(),
         ]));
     }
diff --git a/src/Form/WrapperEntityForm.php b/src/Form/WrapperEntityForm.php
index 21314d3..cf6b826 100644
--- a/src/Form/WrapperEntityForm.php
+++ b/src/Form/WrapperEntityForm.php
@@ -85,14 +85,14 @@ class WrapperEntityForm extends EntityForm {
 
     switch ($status) {
       case SAVED_NEW:
-        drupal_set_message($this->t('Created %label.', [
+        \Drupal::messenger()->addMessage($this->t('Created %label.', [
           '%label' => $entity->label(),
         ]));
         $form_state->setRedirectUrl($entity->toUrl('edit-form'));
         break;
 
       default:
-        drupal_set_message($this->t('Saved %label.', [
+        \Drupal::messenger()->addMessage($this->t('Saved %label.', [
           '%label' => $entity->label(),
         ]));
         $form_state->setRedirectUrl($entity->toUrl('collection'));
diff --git a/tests/src/Functional/BackupMigratePageLoadTest.php b/tests/src/Functional/BackupMigratePageLoadTest.php
index 9fd9bb6..e129b96 100644
--- a/tests/src/Functional/BackupMigratePageLoadTest.php
+++ b/tests/src/Functional/BackupMigratePageLoadTest.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\Tests\backup_migrate\Functional;
 
+use Drupal\Core\File\FileSystemInterface;
 use Drupal\Tests\BrowserTestBase;
 
 /**
@@ -32,7 +33,7 @@ class BackupMigratePageLoadTest extends BrowserTestBase {
     // `admin/config/development/backup_migrate/backups` path will fail without
     // this.
     $path = 'private://backup_migrate/';
-    file_prepare_directory($path, FILE_CREATE_DIRECTORY);
+    \Drupal::service('file_system')->prepareDirectory($path, FileSystemInterface::CREATE_DIRECTORY);
   }
 
   /**
diff --git a/tests/src/Functional/BackupMigratePermissionsTest.php b/tests/src/Functional/BackupMigratePermissionsTest.php
index c13ec52..be1d309 100644
--- a/tests/src/Functional/BackupMigratePermissionsTest.php
+++ b/tests/src/Functional/BackupMigratePermissionsTest.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\Tests\backup_migrate\Functional;
 
+use Drupal\Core\File\FileSystemInterface;
 use Drupal\Tests\BrowserTestBase;
 
 /**
@@ -48,7 +49,7 @@ class BackupMigratePermissionsTest extends BrowserTestBase {
 
     // Ensure the backup_migrate folder exists.
     $path = 'private://backup_migrate/';
-    file_prepare_directory($path, FILE_CREATE_DIRECTORY);
+    \Drupal::service('file_system')->prepareDirectory($path, FileSystemInterface::CREATE_DIRECTORY);
   }
 
   /**
diff --git a/tests/src/Functional/BackupMigrateQuickBackupTest.php b/tests/src/Functional/BackupMigrateQuickBackupTest.php
index 4bb4515..447d995 100644
--- a/tests/src/Functional/BackupMigrateQuickBackupTest.php
+++ b/tests/src/Functional/BackupMigrateQuickBackupTest.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\Tests\backup_migrate\Functional;
 
+use Drupal\Core\File\FileSystemInterface;
 use Drupal\Tests\BrowserTestBase;
 
 /**
@@ -29,7 +30,7 @@ class BackupMigrateQuickBackupTest extends BrowserTestBase {
 
     // Ensure backup_migrate folder exists.
     $path = 'private://backup_migrate/';
-    file_prepare_directory($path, FILE_CREATE_DIRECTORY);
+    \Drupal::service('file_system')->prepareDirectory($path, FileSystemInterface::CREATE_DIRECTORY);
   }
 
   /**
