diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 02c6defc6664b58c81a7c5928e3a3183eadcf5c2..7f9ffbc2a5e2025192555fd3441f784fd0c82432 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -8,6 +8,7 @@ Maillog 8.x-1.x-dev, 2023-xx-xx
   Maillog->mail().
 #1662752 by Eduardo Morales Alberti, pluess, joe-b, miro_dietiker, seanr,
   DamienMcKenna, Maedi: Maillog log table size escalation.
+#1662752 by DamienMcKenna: Minor code cleanup.
 
 
 Maillog 8.x-1.1, 2023-06-01
diff --git a/maillog.module b/maillog.module
index 8a6106aaea5a38b8b533bc1233f2e952543935be..22c6e7ccf7dddf5237b1a4fa7c642ed834776fb2 100644
--- a/maillog.module
+++ b/maillog.module
@@ -31,29 +31,32 @@ function maillog_help($route_name, RouteMatchInterface $route_match) {
  * Implements hook_cron().
  */
 function maillog_cron() {
-  $cron_enabled = \Drupal::config('maillog.settings')->get('cron_enabled');
-  if ($cron_enabled) {
-    $type = \Drupal::config('maillog.settings')->get('keep_limit_type') ?? '';
-    $limit = \Drupal::config('maillog.settings')->get($type) ?? 0;
+  $config = \Drupal::config('maillog.settings');
+  $logger = \Drupal::logger('maillog');
+
+  if ($config->get('cron_enabled')) {
+    $type = $config->get('keep_limit_type') ?? '';
+    $limit = $config->get($type) ?? 0;
 
     $deleted_logs = 0;
 
     try {
-      $deleted_logs = \Drupal::service('maillog.cleaner')->clearMaillogs($type, (int) $limit);
+      $deleted_logs = \Drupal::service('maillog.cleaner')
+        ->clearMaillogs($type, (int) $limit);
     }
     catch (\Exception $e) {
-      \Drupal::logger('maillog')->error(t('Exception when tried to delete the mail logs, reason: @reason', [
+      $logger->error(t('Exception when tried to delete the mail logs, reason: @reason', [
         '@reason' => $e->getMessage(),
       ]));
     }
 
     if (empty($deleted_logs)) {
-      \Drupal::logger('maillog')->info(t('Any log deleted because any log meet the conditions'));
+      $logger->info(t('Any log deleted because any log meet the conditions'));
     }
     else {
-      \Drupal::logger('maillog')->info(t('Deleted @count mail logs from database', ['@count' => $deleted_logs]));
-
+      $logger->info(t('Deleted @count mail logs from database', [
+        '@count' => $deleted_logs,
+      ]));
     }
-
   }
 }