diff --git a/recentlog_user_agent.info b/recentlog_user_agent.info
index 5d9b186..894a287 100644
--- a/recentlog_user_agent.info
+++ b/recentlog_user_agent.info
@@ -1,5 +1,5 @@
 name = Recentlog User Agent
-description = Logs the user agent details from a user in the watch-dog if an error or something else occurs.
+description = Logs the user agent string for a user in the {watchdog} table with each log entry.
 package = Recent log
 core = 7.x
-version = 7.x-1.0
+dependencies[] = dblog
diff --git a/recentlog_user_agent.install b/recentlog_user_agent.install
index 5aa9407..d5a1844 100644
--- a/recentlog_user_agent.install
+++ b/recentlog_user_agent.install
@@ -1,7 +1,8 @@
 <?php
+
 /**
  * @file
- * Defines schema for user agent fields.
+ * Defines schema for the user agent field.
  */
 
 /**
@@ -10,23 +11,20 @@
  * Inserting a new field to Watchdog table.
  */
 function recentlog_user_agent_schema_alter(&$schema) {
-  // Check for watchdog schema.
-  if (isset($schema['watchdog'])) {
-    $schema['watchdog']['fields']['user_agent'] = array(
-      'description' => 'The user agent of the user causing the watchdog mesasge.',
-      'length' => 120,
-      'type' => 'varchar',
-    );
-  }
+  $schema['watchdog']['fields']['user_agent'] = array(
+    'description' => 'The user agent of the user causing the watchdog mesasge.',
+    'length' => 120,
+    'type' => 'varchar',
+  );
 }
 
 /**
  * Implements hook_install().
  *
- * Alters watchdog table schema.
+ * Alters the {watchdog} table schema.
  */
 function recentlog_user_agent_install() {
-  // Get schema.
+  // Get the schema.
   $schema_watchdog = array(
     'watchdog' => array(),
   );
@@ -43,10 +41,10 @@ function recentlog_user_agent_install() {
 /**
  * Implements hook_uninstall().
  *
- * Alters watchdog table schema.
+ * Alters the {watchdog} table schema.
  */
 function recentlog_user_agent_uninstall() {
-  // Get schema.
+  // Get the schema.
   $schema_watchdog = array(
     'watchdog' => array(),
   );
diff --git a/recentlog_user_agent.module b/recentlog_user_agent.module
index 633c58c..684aa9f 100644
--- a/recentlog_user_agent.module
+++ b/recentlog_user_agent.module
@@ -1,4 +1,5 @@
 <?php
+
 /**
  * @file
  * Module file which creates a User Agent field.
@@ -14,113 +15,45 @@ define('RECENTLOG_USER_AGENT_COLUMNSIZE', 120);
 /**
  * Implements hook_watchdog().
  */
-function recentlog_user_agent_watchdog($log_entry) {
-  _recentlog_user_agent_log_user_agent($log_entry);
-}
-
-/**
- * Implements module_preprocess().
- */
-function recentlog_user_agent_preprocess(&$variables, $hook) {
-  // Just on this special page preprocess.
-  if ($hook === 'page') {
-    // Check for right page.
-    // @COMMENT: The last two checks may not be needed. Check this with your
-    // knowledge, while checking the ticket pls.
-    if (in_array('page__admin__reports__event__%', $variables['theme_hook_suggestions']) && isset($variables['page']['content']['system_main']) && isset($variables['page']['content']['system_main']['dblog_table'])) {
-      // Use reference for easy reading.
-      $dblog_table = &$variables['page']['content']['system_main']['dblog_table'];
-
-      // Get report id.
-      $report_id = arg(3);
-
-      // Get user agent.
-      $result = db_select('watchdog', 'w')
-        ->fields('w', array('user_agent'))
-        ->condition('wid', $report_id)
-        ->execute()
-        ->fetchObject();
-
-      // Add additional row.
-      $dblog_table['#rows'][] = array(
-        array('data' => t('User Agent'), 'header' => TRUE),
-        (!empty($result->user_agent) ? $result->user_agent : t('Could not be tracked.')),
-      );
-    }
-  }
-}
-
-/**
- * Logs the user agent.
- *
- * @param array $log_entry
- *   The log entry given to the hook_watchdog() function.
- */
-function _recentlog_user_agent_log_user_agent($log_entry) {
-  if (module_exists('dblog')) {
-    _recentlog_user_agent_log_user_agent_with_dblog($log_entry);
-  }
-}
-
-/**
- * Logs the user agent to the database `watchdog` table.
- *
- * For this to work the 'dblog' module is needed.
- *
- * @param array $log_entry
- *   The log entry given to the hook_watchdog() function.
- */
-function _recentlog_user_agent_log_user_agent_with_dblog($log_entry) {
+function recentlog_user_agent_watchdog(array $log_entry) {
   // Write user agent to database.
   $select_query = db_select('watchdog', 'w')
-    ->fields(
-      'w',
-      array(
-        'wid',
-      )
-    );
+    ->fields('w', array('wid'));
 
   // It can happen that this function is called in a very early bootstrap phase
-  // where the unicode.inc file is not already included. So we are using multi-
-  // byte implementations here and set the encoding manually.
-  if (is_callable('drupal_substr')) {
-    $function = 'drupal_substr';
-  }
-  else {
-    // Set encoding by hand.
-    mb_internal_encoding('utf-8');
-    $function = 'mb_substr';
+  // where the unicode.inc file is not already included.
+  if (!function_exists('drupal_substr')) {
+    require_once DRUPAL_ROOT . '/includes/unicode.inc';
   }
 
   // Copied from dblog.module and used as conditions.
   $conditions = array(
     'uid' => $log_entry['uid'],
-    'type' => $function($log_entry['type'], 0, 64),
+    'type' => drupal_substr($log_entry['type'], 0, 64),
     'message' => $log_entry['message'],
     'variables' => serialize($log_entry['variables']),
     'severity' => $log_entry['severity'],
-    'link' => $function($log_entry['link'], 0, 255),
+    'link' => drupal_substr($log_entry['link'], 0, 255),
     'location' => $log_entry['request_uri'],
     'referer' => $log_entry['referer'],
-    'hostname' => $function($log_entry['ip'], 0, 128),
+    'hostname' => drupal_substr($log_entry['ip'], 0, 128),
     'timestamp' => $log_entry['timestamp'],
   );
 
   // Apply conditions to query.
   foreach ($conditions as $field => $value) {
-    $select_query
-      ->condition($field, $value);
+    $select_query->condition($field, $value);
   }
 
   // Get result.
-  // @COMMENT: This is a really slow query, since none of the fields
-  // is indexed in any kind of way. We need to be careful with these.
+  // @COMMENT: This is a really slow query, since none of the fields are indexed
+  // in any kind of way. We need to be careful with these.
   $result = $select_query->execute()->fetchObject();
 
   // Add user agent.
   if ($result) {
     if (isset($_SERVER['HTTP_USER_AGENT'])) {
-      $user_agent = $function($_SERVER['HTTP_USER_AGENT'], 0, RECENTLOG_USER_AGENT_COLUMNSIZE);
+      $user_agent = drupal_substr($_SERVER['HTTP_USER_AGENT'], 0, RECENTLOG_USER_AGENT_COLUMNSIZE);
     }
     elseif (drupal_is_cli() && defined('DRUSH_VERSION')) {
       $user_agent = 'Drush ' . DRUSH_VERSION;
@@ -139,3 +72,63 @@ function _recentlog_user_agent_log_user_agent_with_dblog($log_entry) {
       ->execute();
   }
 }
+
+/**
+ * Implements module_preprocess().
+ */
+function recentlog_user_agent_preprocess(&$variables, $hook) {
+  // Just on this special page preprocess.
+  if ($hook === 'page') {
+    // Check for right page.
+    // @COMMENT: The last two checks may not be needed. Check this with your
+    // knowledge, while checking the ticket pls.
+    if (in_array('page__admin__reports__event__%', $variables['theme_hook_suggestions']) && isset($variables['page']['content']['system_main']) && isset($variables['page']['content']['system_main']['dblog_table'])) {
+      // Use reference for easy reading.
+      $dblog_table = &$variables['page']['content']['system_main']['dblog_table'];
+
+      // Get report id.
+      $report_id = arg(3);
+
+      // Add additional row.
+      $dblog_table['#rows'][] = array(
+        array('data' => t('User Agent'), 'header' => TRUE),
+        recentlog_get_user_agent($report_id),
+      );
+    }
+  }
+}
+
+/**
+ * Gets a user agent string from a watchdog entry.
+ *
+ * @param int $wid
+ *   The ID of the watchdog entry.
+ *
+ * @return string
+ *   The user agent string from the {watchdog} table or a sensible replacement
+ *   if not found.
+ */
+function recentlog_get_user_agent($wid) {
+  $result = db_select('watchdog', 'w')
+    ->fields('w', array('user_agent'))
+    ->condition('wid', $wid)
+    ->execute()
+    ->fetchField();
+  if (!$result) {
+    return t("Could not be tracked.");
+  }
+  return $result;
+}
+
+/**
+ * Implements hook_better_watchdog_ui_event_page_alter().
+ */
+function recentlog_user_agent_better_watchdog_ui_event_page_alter(&$watchdog, $view_mode) {
+  $watchdog->content['user_agent'] = array(
+    '#type' => 'item',
+    '#title' => t('User Agent'),
+    '#markup' => recentlog_get_user_agent($watchdog->wid),
+  );
+  // Put the operations on the bottom.
+  $watchdog->content['operations']['#weight'] = 10;
+}
