diff --git a/nodeorder.info.yml b/nodeorder.info.yml
index 5b021e7..3b20d9d 100644
--- a/nodeorder.info.yml
+++ b/nodeorder.info.yml
@@ -1,6 +1,6 @@
 name: 'Node Order'
 description: 'Allows the ordering of nodes within taxonomy terms.'
-core: 8.x
+core_version_requirement: ^8.7.7 || ^9
 configure: nodeorder.admin
 dependencies:
   - drupal:node
diff --git a/nodeorder.install b/nodeorder.install
index fa397f4..6803f52 100644
--- a/nodeorder.install
+++ b/nodeorder.install
@@ -28,7 +28,7 @@ function nodeorder_install() {
   $keys['fields']['weight'] = $spec;
 
   // Add the column to the table.
-  db_add_field('taxonomy_index', 'weight', $spec, $keys);
+  \Drupal::database()->schema()->addField('taxonomy_index', 'weight', $spec, $keys);
 
   // Set the weight of the nodeorder module ensure that nodeorder can alter
   // forms after the taxonomy module.
@@ -41,6 +41,7 @@ function nodeorder_install() {
  * Drops field 'weight' from core table 'taxonomy_index'.
  */
 function nodeorder_uninstall() {
-  db_drop_index('taxonomy_index', 'weight');
-  db_drop_field('taxonomy_index', 'weight');
+  $schema = \Drupal::database()->schema();
+  $schema->dropIndex('taxonomy_index', 'weight');
+  $schema->dropField('taxonomy_index', 'weight');
 }
diff --git a/nodeorder.module b/nodeorder.module
index 25236f4..5fe4cee 100755
--- a/nodeorder.module
+++ b/nodeorder.module
@@ -9,7 +9,6 @@ use Drupal\Core\Cache\Cache;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Url;
 use Drupal\node\NodeInterface;
-use Drupal\taxonomy\Entity\Vocabulary;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Routing\RouteMatchInterface;
 use Drupal\taxonomy\Entity\Term;
@@ -40,7 +39,7 @@ function nodeorder_entity_operation(EntityInterface $entity) {
   if ($entity instanceof Term) {
     /** @var \Drupal\nodeorder\NodeOrderManagerInterface $nodeorder_manager */
     $nodeorder_manager = \Drupal::service('nodeorder.manager');
-    if ($nodeorder_manager->vocabularyIsOrderable($entity->getVocabularyId())) {
+    if ($nodeorder_manager->vocabularyIsOrderable($entity->bundle())) {
       $operations['order'] = [
         'title' => t('Order'),
         'query' => \Drupal::destination()->getAsArray(),
@@ -90,9 +89,10 @@ function nodeorder_taxonomy_vocabulary_form_submit($form, FormStateInterface $fo
   $nodeorder_manager = \Drupal::service('nodeorder.manager');
 
   $vocabulary = $form_state->getFormObject()->getEntity();
-  $config = \Drupal::configFactory()->getEditable('nodeorder.settings');
+  $config = \Drupal::service('config.nodeorder_settings');
   $orderable = $form_state->getValue('orderable');
   $vocabularies = $config->get('vocabularies');
+  $term_storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term');
 
   if ($orderable && empty($vocabularies[$vocabulary->id()])) {
     // Switching from non-orderable to orderable.
@@ -100,7 +100,7 @@ function nodeorder_taxonomy_vocabulary_form_submit($form, FormStateInterface $fo
 
     // Set weight to nid for all rows in term_node where the tid is in this
     // vocabulary.
-    $tree = \Drupal::service('entity_type.manager')->getStorage("taxonomy_term")->loadTree($vocabulary->id());
+    $tree = $term_storage->loadTree($vocabulary->id());
     $tids = [];
     foreach ($tree as $term) {
       $tids[] = $term->tid;
@@ -139,7 +139,7 @@ function nodeorder_taxonomy_vocabulary_form_submit($form, FormStateInterface $fo
 
     // Set weight to 0 for all rows in term_node where the tid is in this
     // vocabulary.
-    $tree = \Drupal::service('entity_type.manager')->getStorage("taxonomy_term")->loadTree($vocabulary->id());
+    $tree = $term_storage->loadTree($vocabulary->id());
     $tids = [];
     foreach ($tree as $term) {
       $tids[] = $term->tid;
diff --git a/nodeorder.services.yml b/nodeorder.services.yml
index a6729a1..243a76b 100755
--- a/nodeorder.services.yml
+++ b/nodeorder.services.yml
@@ -6,4 +6,4 @@ services:
 
   nodeorder.manager:
     class: Drupal\nodeorder\NodeOrderManager
-    arguments: ['@config.factory', '@entity.manager', '@cache.default']
+    arguments: ['@config.factory', '@database', '@entity_type.manager', '@cache.default']
diff --git a/src/Access/NodeOrderAccess.php b/src/Access/NodeOrderAccess.php
index c5b6b73..32f654e 100644
--- a/src/Access/NodeOrderAccess.php
+++ b/src/Access/NodeOrderAccess.php
@@ -62,12 +62,13 @@ class NodeOrderAccess implements ContainerInjectionInterface {
    * Vocabulary orderable.
    *
    * @param \Drupal\taxonomy\Entity\Term $taxonomy_term
+   *   Taxonomy term.
    *
    * @return \Drupal\Core\Access\AccessResult
    *   Access result.
    */
   public function isVocabularyOrderable(Term $taxonomy_term) {
-    $vocabulary_id = $taxonomy_term->getVocabularyId();
+    $vocabulary_id = $taxonomy_term->bundle();
 
     return $this->nodeOrderManager->vocabularyIsOrderable($vocabulary_id)
       ? AccessResult::allowed()
@@ -78,6 +79,7 @@ class NodeOrderAccess implements ContainerInjectionInterface {
    * Administer order.
    *
    * @param \Drupal\taxonomy\Entity\Term $taxonomy_term
+   *   Taxonomy term.
    *
    * @return \Drupal\Core\Access\AccessResult
    *   Access result.
diff --git a/src/Form/NodeorderAdminForm.php b/src/Form/NodeorderAdminForm.php
index bb952d2..8770ff4 100644
--- a/src/Form/NodeorderAdminForm.php
+++ b/src/Form/NodeorderAdminForm.php
@@ -11,7 +11,7 @@ use Drupal\Core\Form\FormStateInterface;
 class NodeorderAdminForm extends ConfigFormBase {
 
   /**
-   * {@inheritdoc}.
+   * {@inheritdoc}
    */
   public function getFormId() {
     return 'nodeorder_admin';
diff --git a/src/NodeOrderListBuilder.php b/src/NodeOrderListBuilder.php
index d180c79..dc70d79 100644
--- a/src/NodeOrderListBuilder.php
+++ b/src/NodeOrderListBuilder.php
@@ -134,9 +134,10 @@ class NodeOrderListBuilder extends EntityListBuilder implements FormInterface {
 
     $this->entitiesCount = (int) $count_query->execute()->fetchField();
 
-    // Method load will be triggered later, if we pass empty array as an argument,
-    // method will be load all entities with type node, will be passed -1 as an
-    // allowed ID for node to prevent loading all entities.
+    // Method load will be triggered later, if we pass empty array as
+    // an argument, method will be load all entities with type node,
+    // will be passed -1 as an allowed ID for node to prevent loading
+    // all entities.
     // Case for term without nodes.
     return $this->nodesWeight ? array_keys($this->nodesWeight) : [-1];
   }
diff --git a/src/NodeOrderManager.php b/src/NodeOrderManager.php
index 4dbc209..a14ff25 100644
--- a/src/NodeOrderManager.php
+++ b/src/NodeOrderManager.php
@@ -3,10 +3,11 @@
 namespace Drupal\nodeorder;
 
 use Drupal\Core\Cache\Cache;
+use Drupal\Core\Config\ConfigFactoryInterface;
+use Drupal\Core\Database\Connection;
+use Drupal\Core\Entity\EntityTypeManagerInterface;
 use Drupal\node\NodeInterface;
 use Drupal\taxonomy\Entity\Vocabulary;
-use Drupal\Core\Config\ConfigFactoryInterface;
-use Drupal\Core\Entity\EntityManagerInterface;
 use Drupal\Core\Cache\CacheBackendInterface;
 
 /**
@@ -15,11 +16,18 @@ use Drupal\Core\Cache\CacheBackendInterface;
 class NodeOrderManager implements NodeOrderManagerInterface {
 
   /**
-   * The configuration object factory.
+   * The configuration object.
    *
-   * @var \Drupal\Core\Config\ConfigFactoryInterface
+   * @var \Drupal\Core\Config\ImmutableConfig
    */
-  protected $configFactory;
+  protected $config;
+
+  /**
+   * The current database connection.
+   *
+   * @var \Drupal\Core\Database\Connection
+   */
+  protected $database;
 
   /**
    * Taxonomy term storage.
@@ -38,16 +46,21 @@ class NodeOrderManager implements NodeOrderManagerInterface {
   /**
    * Constructs a NodeOrderManager object.
    *
-   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
-   *   The configuration object factory.
-   * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
+   * @param \Drupal\Core\Config\ConfigFactoryInterface $config
+   *   The configuration object.
+   * @param \Drupal\Core\Database\Connection $database
+   *   The current database connection.
+   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
    *   The entity manager.
    * @param \Drupal\Core\Cache\CacheBackendInterface $cache
    *   Default cache bin.
+   *
+   * @throws \Throwable
    */
-  public function __construct(ConfigFactoryInterface $config_factory, EntityManagerInterface $entity_manager, CacheBackendInterface $cache) {
-    $this->configFactory = $config_factory;
-    $this->termStorage = $entity_manager->getStorage('taxonomy_term');
+  public function __construct(ConfigFactoryInterface $config, Connection $database, EntityTypeManagerInterface $entity_type_manager, CacheBackendInterface $cache) {
+    $this->database = $database;
+    $this->config = $config->get('nodeorder.settings');
+    $this->termStorage = $entity_type_manager->getStorage('taxonomy_term');
     $this->cache = $cache;
   }
 
@@ -57,7 +70,7 @@ class NodeOrderManager implements NodeOrderManagerInterface {
   public function addToList(NodeInterface $node, $tid) {
     // Append new orderable node. Get the cached weights.
     $weights = $this->getTermMinMax($tid);
-    \Drupal::database()->update('taxonomy_index')
+    $this->database->update('taxonomy_index')
       ->fields(['weight' => $weights['min'] - 1])
       ->condition('nid', $node->id())
       ->condition('tid', $tid)
@@ -65,7 +78,7 @@ class NodeOrderManager implements NodeOrderManagerInterface {
     // If new node out of range, push top nodes down filling the order gap
     // this is when old list's min weight is top range
     // except when new orderable node increases range (new list is not even).
-    $taxonomy_nids = \Drupal::database()->select('taxonomy_index', 'ti')
+    $taxonomy_nids = $this->database->select('taxonomy_index', 'ti')
       ->fields('ti', ['nid'])
       ->condition('ti.tid', $tid)
       ->orderBy('ti.weight')
@@ -79,7 +92,7 @@ class NodeOrderManager implements NodeOrderManagerInterface {
       $top_range_nids = [];
       $previous_weight = $weights['min'] - 2;
       foreach ($taxonomy_nids as $taxonomy_nid) {
-        $taxonomy_node_weight = \Drupal::database()->select('taxonomy_index', 'i')
+        $taxonomy_node_weight = $this->database->select('taxonomy_index', 'i')
           ->fields('i', ['weight'])
           ->condition('tid', $tid)
           ->condition('nid', $taxonomy_nid)
@@ -93,7 +106,7 @@ class NodeOrderManager implements NodeOrderManagerInterface {
         $top_range_nids[] = $taxonomy_nid;
       }
       // Move top nodes down.
-      $query = \Drupal::database()->update('taxonomy_index');
+      $query = $this->database->update('taxonomy_index');
       $query->expression('weight', 'weight + 1');
       $query->condition('nid', $top_range_nids, 'IN')
         ->condition('tid', $tid)
@@ -124,7 +137,7 @@ class NodeOrderManager implements NodeOrderManagerInterface {
     }
 
     if (!isset($min_weights[$tid]) || !isset($max_weights[$tid])) {
-      $query = \Drupal::database()->select('taxonomy_index', 'i')
+      $query = $this->database->select('taxonomy_index', 'i')
         ->fields('i', ['tid'])
         ->condition('tid', $tid)
         ->groupBy('tid');
@@ -146,7 +159,7 @@ class NodeOrderManager implements NodeOrderManagerInterface {
    * {@inheritdoc}
    */
   public function vocabularyIsOrderable($vid) {
-    $vocabularies = $this->configFactory->get('nodeorder.settings')->get('vocabularies');
+    $vocabularies = $this->config->get('vocabularies');
     return !empty($vocabularies[$vid]);
   }
 
@@ -163,7 +176,7 @@ class NodeOrderManager implements NodeOrderManagerInterface {
       }
       foreach ($tids as $index => $tid) {
         $term = $this->termStorage->load($tid);
-        $tree = $this->termStorage->loadTree($term->getVocabularyId(), $tid, $depth);
+        $tree = $this->termStorage->loadTree($term->bundle(), $tid, $depth);
         $descendant_tids[] = array_merge([$tid], array_map(function ($value) {
           return $value->id();
         }, $tree));
@@ -177,7 +190,7 @@ class NodeOrderManager implements NodeOrderManagerInterface {
       }
       else {
         $args = [];
-        $query = \Drupal::database()->select('node', 'n');
+        $query = $this->database->select('node', 'n');
         $query->join('node_field_data', 'nd', 'nd.nid = n.nid');
         $query->condition('nd.status', 1);
         foreach ($descendant_tids as $index => $tids) {
@@ -194,21 +207,21 @@ class NodeOrderManager implements NodeOrderManagerInterface {
 
       if ($pager) {
         if ($count == -1) {
-          $count = $this->configFactory->get('nodeorder.settings')->get('default_nodes_main');
+          $count = $this->config->get('default_nodes_main');
         }
         $result = pager_query($sql, $count, 0, $sql_count, $args);
       }
       else {
         if ($count == -1) {
-          $count = $this->configFactory->get('nodeorder.settings')->get('feed_default_items');
+          $count = $this->config->get('feed_default_items');
         }
 
         if ($count == 0) {
-          // TODO Please convert this statement to the D7 database API syntax.
+          // @todo: Please convert this statement to the D7 database API syntax.
           $result = $query->execute();
         }
         else {
-          // TODO Please convert this statement to the D7 database API syntax.
+          // @todo: Please convert this statement to the D7 database API syntax.
           $result = db_query_range($sql, $args);
         }
       }
@@ -264,13 +277,13 @@ class NodeOrderManager implements NodeOrderManagerInterface {
     }
     else {
       $vocabularies = [];
-      foreach ($this->configFactory->get('nodeorder.settings')->get('vocabularies') as $vid => $orderable) {
+      foreach ($this->config->get('vocabularies') as $vid => $orderable) {
         if ($orderable) {
           $vocabularies[] = $vid;
         }
       }
       if (!empty($vocabularies)) {
-        $query = \Drupal::database()->select('taxonomy_index', 'i');
+        $query = $this->database->select('taxonomy_index', 'i');
         $query->join('taxonomy_term_data', 'd', 'd.tid = i.tid');
         $query->condition('i.nid', $node->id())
           ->condition('d.vid', $vocabularies, 'IN')
@@ -317,7 +330,7 @@ class NodeOrderManager implements NodeOrderManagerInterface {
    * {@inheritdoc}
    */
   public function handleListsDecrease($tid) {
-    $taxonomy_nids = \Drupal::database()->select('taxonomy_index', 'ti')
+    $taxonomy_nids = $this->database->select('taxonomy_index', 'ti')
       ->fields('ti', ['nid'])
       ->condition('ti.tid', $tid)
       ->orderBy('ti.weight')
@@ -334,7 +347,7 @@ class NodeOrderManager implements NodeOrderManagerInterface {
     if ($border_out_of_range) {
       $weight = -$range_border;
       foreach ($taxonomy_nids as $nid) {
-        \Drupal::database()->update('taxonomy_index')
+        $this->database->update('taxonomy_index')
           ->fields(['weight' => $weight])
           ->condition('nid', $nid)
           ->condition('tid', $tid)
diff --git a/src/NodeOrderManagerInterface.php b/src/NodeOrderManagerInterface.php
index 86deff6..915ba0a 100644
--- a/src/NodeOrderManagerInterface.php
+++ b/src/NodeOrderManagerInterface.php
@@ -50,7 +50,6 @@ interface NodeOrderManagerInterface {
    *       http://drupal.org/node/25801 if you find this sort of copy and
    *       paste upsetting...
    *
-   *
    * @param array $tids
    *   An array of term IDs to match.
    * @param string $operator
diff --git a/src/Tests/NodeorderCrudTest.php b/src/Tests/NodeorderCrudTest.php
index 0550d8e..544fa30 100644
--- a/src/Tests/NodeorderCrudTest.php
+++ b/src/Tests/NodeorderCrudTest.php
@@ -3,7 +3,7 @@
 namespace Drupal\nodeorder\Tests;
 
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
-use Drupal\taxonomy\Tests\TaxonomyTestBase;
+use Drupal\Tests\taxonomy\Functional\TaxonomyTestBase;
 
 /**
  * Test CRUD operations that Nodeorder relies on.
@@ -12,6 +12,11 @@ use Drupal\taxonomy\Tests\TaxonomyTestBase;
  */
 class NodeorderCrudTest extends TaxonomyTestBase {
 
+  /**
+   * {@inheritdoc}
+   */
+  protected $defaultTheme = 'stark';
+
   /**
    * {@inheritdoc}
    */
@@ -49,7 +54,7 @@ class NodeorderCrudTest extends TaxonomyTestBase {
     $this->nodeOrderManager = $this->container->get('nodeorder.manager');
 
     $this->drupalLogin($this->drupalCreateUser([
-      'administer taxonomy', 'bypass node access', 'order nodes within categories'
+      'administer taxonomy', 'bypass node access', 'order nodes within categories',
     ]));
     $this->vocabulary = $this->createVocabulary();
 
@@ -280,9 +285,9 @@ class NodeorderCrudTest extends TaxonomyTestBase {
 
     // Term 2 ordering should remain unchanged.
     $expected = [
-      $node1->id() => 0,
-      $node3->id() => -1,
-      $node4->id() => -2,
+      $node1->id() => -2,
+      $node3->id() => 1,
+      $node4->id() => 2,
     ];
     $this->assertNodeorderByTid($term2->id(), $expected);
   }
@@ -296,7 +301,7 @@ class NodeorderCrudTest extends TaxonomyTestBase {
    *   Expected order keyed by node ID.
    */
   protected function assertNodeorderByTid($tid, array $expected) {
-    $order = \Drupal::database()->select('taxonomy_index', 'ti')
+    $order = \Drupal::service('database')->select('taxonomy_index', 'ti')
       ->fields('ti', ['nid', 'weight'])
       ->condition('tid', $tid)
       ->execute()
diff --git a/tests/src/Functional/NodeorderPermissionsTest.php b/tests/src/Functional/NodeorderPermissionsTest.php
index 849ca50..96ca2f6 100644
--- a/tests/src/Functional/NodeorderPermissionsTest.php
+++ b/tests/src/Functional/NodeorderPermissionsTest.php
@@ -18,6 +18,11 @@ class NodeorderPermissionsTest extends BrowserTestBase {
     createTerm as drupalCreateTerm;
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  protected $defaultTheme = 'stark';
+
   /**
    * The configuration factory service.
    *
diff --git a/tests/src/Kernel/NodeorderConfigSchemaTest.php b/tests/src/Kernel/NodeorderConfigSchemaTest.php
index d3190fe..a65d308 100644
--- a/tests/src/Kernel/NodeorderConfigSchemaTest.php
+++ b/tests/src/Kernel/NodeorderConfigSchemaTest.php
@@ -88,7 +88,7 @@ class NodeorderConfigSchemaTest extends KernelTestBase {
           'link_to_ordering_page_taxonomy_admin' => $this->randomString(),
         ],
         FALSE,
-      ]
+      ],
     ];
   }
 
