diff --git a/admincss.module b/admincss.module
index 9dca575..f1bf7c9 100644
--- a/admincss.module
+++ b/admincss.module
@@ -4,50 +4,33 @@
  * @file
  * Hook implementations for the Admin CSS module.
  */
-
+use Drupal\Core\Hook\Attribute\LegacyHook;
+use Drupal\admincss\Hook\AdmincssHooks;
 use Drupal\Core\Cache\CacheableMetadata;
 use Drupal\Core\Routing\RouteMatchInterface;
 
 /**
  * Implements hook_help().
  */
+#[LegacyHook]
 function admincss_help($route_name, RouteMatchInterface $route_match) {
-  switch ($route_name) {
-    case 'help.page.admincss':
-      $output = '';
-      $output .= '<h3>' . t('About') . '</h3>';
-      $output .= '<p>' . t('The Admin CSS module provides a way to add custom CSS to the site.') . '</p>';
-      return $output;
-  }
+  return \Drupal::service(AdmincssHooks::class)->help($route_name, $route_match);
 }
 
 /**
  * Implements hook_page_attachments().
  */
-function admincss_page_attachments(array &$attachments) {
-  $theme = \Drupal::theme()->getActiveTheme()->getName();
-  $default_theme = \Drupal::config('system.theme')->get('default');
-  if ($default_theme === $theme) {
-    if (file_exists('public://admin-style.css')) {
-      $attachments['#attached']['library'][] = $theme . '/admincss.admincss';
-    }
-
-    // Add the admin css cache tags.
-    $admincss_config = \Drupal::config('admincss.settings');
-    $cacheable_metadata = CacheableMetadata::createFromObject($admincss_config);
-    $cacheable_metadata->applyTo($attachments);
-  }
+#[LegacyHook]
+function admincss_page_attachments(array &$attachments)
+{
+    \Drupal::service(AdmincssHooks::class)->pageAttachments($attachments);
 }
 
 /**
  * Implements hook_library_info_alter().
  */
-function admincss_library_info_alter(&$libraries, $extension) {
-  $theme = \Drupal::theme()->getActiveTheme()->getName();
-  if ($theme === $extension) {
-    if (!isset($libraries['admincss.admincss']['css'])) {
-      // Add the library to the active theme with a relatively high weight.
-      $libraries['admincss.admincss']['css']['theme']['public://admin-style.css']['weight'] = 9999;
-    }
-  }
+#[LegacyHook]
+function admincss_library_info_alter(&$libraries, $extension)
+{
+    \Drupal::service(AdmincssHooks::class)->libraryInfoAlter($libraries, $extension);
 }
diff --git a/admincss.services.yml b/admincss.services.yml
new file mode 100644
index 0000000..54dce53
--- /dev/null
+++ b/admincss.services.yml
@@ -0,0 +1,5 @@
+
+services:
+  Drupal\admincss\Hook\AdmincssHooks:
+    class: Drupal\admincss\Hook\AdmincssHooks
+    autowire: true
diff --git a/src/Form/AdminCssEditor.php b/src/Form/AdminCssEditor.php
index 148e271..74f2184 100644
--- a/src/Form/AdminCssEditor.php
+++ b/src/Form/AdminCssEditor.php
@@ -2,6 +2,8 @@
 
 namespace Drupal\admincss\Form;
 
+use Drupal\Component\Utility\DeprecationHelper;
+use Drupal\Core\File\FileExists;
 use Drupal\Core\Asset\AssetCollectionOptimizerInterface;
 use Drupal\Core\Cache\CacheTagsInvalidatorInterface;
 use Drupal\Core\Config\ConfigFactoryInterface;
@@ -148,7 +150,7 @@ class AdminCssEditor extends ConfigFormBase {
         // Ignore and continue.
       }
     }
-    elseif (\Drupal::service('file.repository')->writeData($custom_css, $destination_uri, FileSystemInterface::EXISTS_REPLACE)) {
+    elseif (\Drupal::service('file.repository')->writeData($custom_css, $destination_uri, DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.3.0', fn() => FileExists::Replace, fn() => FileSystemInterface::EXISTS_REPLACE))) {
       $changed = TRUE;
     }
 
@@ -191,7 +193,7 @@ class AdminCssEditor extends ConfigFormBase {
     }
     else {
       // Regenerate the dummy query string.
-      _drupal_flush_css_js();
+      DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.2.0', fn() => \Drupal::service('asset.query_string')->reset(), fn() => _drupal_flush_css_js());
     }
   }
 
diff --git a/src/Hook/AdmincssHooks.php b/src/Hook/AdmincssHooks.php
new file mode 100644
index 0000000..01938a8
--- /dev/null
+++ b/src/Hook/AdmincssHooks.php
@@ -0,0 +1,61 @@
+<?php
+
+namespace Drupal\admincss\Hook;
+
+use Drupal\Core\Cache\CacheableMetadata;
+use Drupal\Core\Routing\RouteMatchInterface;
+use Drupal\Core\Hook\Attribute\Hook;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
+/**
+ * Hook implementations for admincss.
+ */
+class AdmincssHooks
+{
+    use StringTranslationTrait;
+    /**
+     * Implements hook_help().
+     */
+    #[Hook('help')]
+    public function help($route_name, \Drupal\Core\Routing\RouteMatchInterface $route_match)
+    {
+        switch ($route_name) {
+            case 'help.page.admincss':
+                $output = '';
+                $output .= '<h3>' . $this->t('About') . '</h3>';
+                $output .= '<p>' . $this->t('The Admin CSS module provides a way to add custom CSS to the site.') . '</p>';
+                return $output;
+        }
+    }
+    /**
+     * Implements hook_page_attachments().
+     */
+    #[Hook('page_attachments')]
+    public function pageAttachments(array &$attachments)
+    {
+        $theme = \Drupal::theme()->getActiveTheme()->getName();
+        $default_theme = \Drupal::config('system.theme')->get('default');
+        if ($default_theme === $theme) {
+            if (file_exists('public://admin-style.css')) {
+                $attachments['#attached']['library'][] = $theme . '/admincss.admincss';
+            }
+            // Add the admin css cache tags.
+            $admincss_config = \Drupal::config('admincss.settings');
+            $cacheable_metadata = \Drupal\Core\Cache\CacheableMetadata::createFromObject($admincss_config);
+            $cacheable_metadata->applyTo($attachments);
+        }
+    }
+    /**
+     * Implements hook_library_info_alter().
+     */
+    #[Hook('library_info_alter')]
+    public function libraryInfoAlter(&$libraries, $extension)
+    {
+        $theme = \Drupal::theme()->getActiveTheme()->getName();
+        if ($theme === $extension) {
+            if (!isset($libraries['admincss.admincss']['css'])) {
+                // Add the library to the active theme with a relatively high weight.
+                $libraries['admincss.admincss']['css']['theme']['public://admin-style.css']['weight'] = 9999;
+            }
+        }
+    }
+}
