diff --git a/saml_rules.info.yml b/saml_rules.info.yml
index 775c743..ec86fe5 100644
--- a/saml_rules.info.yml
+++ b/saml_rules.info.yml
@@ -4,6 +4,7 @@ description: Configure rules based on response data from SAML provider.
 package: User authentication
 version: 8.x-1.x
 core: 8.x
+core_version_requirement: ^8 || ^9
 
 dependencies:
   - samlauth:samlauth
diff --git a/src/EventSubscriber/SAMLRulesAnonymousLogin.php b/src/EventSubscriber/SAMLRulesAnonymousLogin.php
index 700a2f4..5cde1be 100644
--- a/src/EventSubscriber/SAMLRulesAnonymousLogin.php
+++ b/src/EventSubscriber/SAMLRulesAnonymousLogin.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\saml_rules\EventSubscriber;
 
+use Drupal\Core\Url;
 use Symfony\Component\HttpFoundation\RedirectResponse;
 use Symfony\Component\HttpKernel\KernelEvents;
 use Symfony\Component\HttpKernel\Event\GetResponseEvent;
@@ -39,7 +40,7 @@ class SAMLRulesAnonymousLogin implements EventSubscriberInterface {
       // otherwise, redirect to login page. Admin panel to add these paths.
       //$route_name = \Drupal::routeMatch()->getRouteName();
 
-      $response = new RedirectResponse(\Drupal::url('user.login'));
+      $response = new RedirectResponse(Url::fromRoute('user.login')->toString());
       $response->send();
     }
 
@@ -50,7 +51,7 @@ class SAMLRulesAnonymousLogin implements EventSubscriberInterface {
       \Drupal::routeMatch()->getRouteName() == 'user.login' &&
       !empty($redirect)) {
 
-      $response = new RedirectResponse(\Drupal::url('user.login'));
+      $response = new RedirectResponse(Url::fromRoute('user.login')->toString());
       $response->send();
     }
   }
diff --git a/src/Form/SAMLRulesAuthenticationRuleDeleteForm.php b/src/Form/SAMLRulesAuthenticationRuleDeleteForm.php
index aa414df..f8f98d0 100755
--- a/src/Form/SAMLRulesAuthenticationRuleDeleteForm.php
+++ b/src/Form/SAMLRulesAuthenticationRuleDeleteForm.php
@@ -37,7 +37,7 @@ class SAMLRulesAuthenticationRuleDeleteForm extends ConfirmFormBase {
     $rules = $config->get('rules');
     unset($rules[$this->rule_machine_name]);
     $config->set('rules', $rules)->save();
-    drupal_set_message($this->t('The authentication rule %rule_name was deleted.', [
+    $this->messenger()->addStatus($this->t('The authentication rule %rule_name was deleted.', [
       '%rule_name' => $this->rule_machine_name,
     ]));
     $form_state->setRedirect('saml_rules.authentication_rules_view');
diff --git a/src/Form/SAMLRulesAuthenticationRuleForm.php b/src/Form/SAMLRulesAuthenticationRuleForm.php
index 81d781d..257d19c 100644
--- a/src/Form/SAMLRulesAuthenticationRuleForm.php
+++ b/src/Form/SAMLRulesAuthenticationRuleForm.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\saml_rules\Form;
 
+use Drupal\Core\Url;
 use Drupal\Core\Form\ConfigFormBase;
 use Drupal\Core\Form\FormStateInterface;
 use Symfony\Component\HttpFoundation\RedirectResponse;
@@ -73,8 +74,8 @@ class SAMLRulesAuthenticationRuleForm extends ConfigFormBase {
     // If there are no SAML keys, then we can't do anything. Likely because they have not
     // logged in via SAML provider yet.
     if (empty($saml_fields)) {
-      drupal_set_message('Cannot configure Authentication Rules because there are no available SAML attributes. That may be because you have not interfaced with the SAML service yet. Login using the SAML service and this should provide the SAML response attributes needed.', 'error');
-      $response = new RedirectResponse(\Drupal::url('saml_rules.authentication_rules_view'));
+      $this->messenger()->addError('Cannot configure Authentication Rules because there are no available SAML attributes. That may be because you have not interfaced with the SAML service yet. Login using the SAML service and this should provide the SAML response attributes needed.');
+      $response = new RedirectResponse(Url::fromRoute('saml_rules.authentication_rules_view')->toString());
       $response->send();
     }
 
diff --git a/src/Form/SAMLRulesUserFieldRuleDeleteForm.php b/src/Form/SAMLRulesUserFieldRuleDeleteForm.php
index e8b3f1c..596dcbf 100755
--- a/src/Form/SAMLRulesUserFieldRuleDeleteForm.php
+++ b/src/Form/SAMLRulesUserFieldRuleDeleteForm.php
@@ -37,7 +37,7 @@ class SAMLRulesUserFieldRuleDeleteForm extends ConfirmFormBase {
     $rules = $config->get('rules');
     unset($rules[$this->rule_machine_name]);
     $config->set('rules', $rules)->save();
-    drupal_set_message($this->t('The user field rule %rule_name was deleted.', [
+    $this->messenger()->addStatus($this->t('The user field rule %rule_name was deleted.', [
       '%rule_name' => $this->rule_machine_name,
     ]));
     $form_state->setRedirect('saml_rules.user_field_rules_view');
diff --git a/src/Form/SAMLRulesUserFieldRuleForm.php b/src/Form/SAMLRulesUserFieldRuleForm.php
index 66219dc..4cbce85 100644
--- a/src/Form/SAMLRulesUserFieldRuleForm.php
+++ b/src/Form/SAMLRulesUserFieldRuleForm.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\saml_rules\Form;
 
+use Drupal\Core\Url;
 use Drupal\Core\Form\ConfigFormBase;
 use Drupal\Core\Form\FormStateInterface;
 use Symfony\Component\HttpFoundation\RedirectResponse;
@@ -54,8 +55,8 @@ class SAMLRulesUserFieldRuleForm extends ConfigFormBase {
     // If there are no SAML keys, then we can't do anything. Likely because they have not
     // logged in via SAML provider yet.
     if (empty($saml_fields)) {
-      drupal_set_message('Cannot configure User Field Rules because there are no available SAML attributes. That may be because you have not interfaced with the SAML service yet. Login using the SAML service and this should provide the SAML response attributes needed.', 'error');
-      $response = new RedirectResponse(\Drupal::url('saml_rules.user_field_rules_view'));
+      $this->messenger()->addError('Cannot configure User Field Rules because there are no available SAML attributes. That may be because you have not interfaced with the SAML service yet. Login using the SAML service and this should provide the SAML response attributes needed.');
+      $response = new RedirectResponse(Url::fromRoute('saml_rules.user_field_rules_view')->toString());
       $response->send();
     }
     
