diff --git a/sites/all/modules/contrib/recently_read/recently_read.module b/sites/all/modules/contrib/recently_read/recently_read.module
index 4782bd7..6f35fc2 100644
--- a/sites/all/modules/contrib/recently_read/recently_read.module
+++ b/sites/all/modules/contrib/recently_read/recently_read.module
@@ -54,8 +54,7 @@ function recently_read_entity_view($entity, $type, $view_mode, $langcode) {
   list($entity_id, $vid, $bundle) = entity_extract_ids($type, $entity);
 
   //Write the record to DB.
-  //TODO::implements hook_cron to clean up the outdated data from the DB.
-  if (session_api_get_sid() && $entity_id) {
+  if (($sid = session_api_get_sid()) && $entity_id) {
     db_merge('recently_read')
       ->key(array(
         'sid' => session_api_get_sid(),
@@ -68,6 +67,35 @@ function recently_read_entity_view($entity, $type, $view_mode, $langcode) {
         'timestamp' => REQUEST_TIME,
       ))
       ->execute();
+
+    // Select the oldest timestamp of the $max_record newest records to find
+    // the cutoff date, and delete all older records for this sid/entity pair.
+    // Doing this during cron would create involve an excessive number or
+    // queries, or a few very expensive queries.
+
+    $max_record = (int)$config[$type]['max_record'];
+    // Put max_record into the query directly, otherwise Drupal will quote it
+    // and break the SQL. There's probably a way to do this with nested
+    // db_select statements, but it was getting ridiculous when I tried.
+    $cutoff_time = db_query(
+        "SELECT min(`timestamp`) FROM
+          (SELECT `timestamp`
+            FROM {recently_read}
+            WHERE type = :type AND sid = :sid
+            ORDER BY `timestamp` DESC
+            LIMIT $max_record) s",
+          array(
+            ':sid' => $sid,
+            ':type' => $type
+          ))
+      ->fetchField();
+
+    $del = db_delete("recently_read")
+      ->condition("sid", $sid)
+      ->condition("type", $type)
+      ->condition("timestamp", $cutoff_time, "<")
+      ->execute();
+
   }
 }
