diff --git a/twitter_pull.module b/twitter_pull.module
index 48832ec..087a51e 100644
--- a/twitter_pull.module
+++ b/twitter_pull.module
@@ -5,8 +5,9 @@
  * Twitter Pull module.
  */

-define ('TWITTER_PULL_NUM_ITEMS', 5);
-define ('TWITTER_PULL_CACHE_LENGTH', 20); //-- cache for 20 minutes
+define ('TWITTER_PULL_NUM_ITEMS', 6);
+define ('TWITTER_PULL_CACHE_LENGTH', 0); //-- Refresh every 20 mins, or 0 for CACHE_PERMANENT
+define ('TWITTER_PULL_REFRESH_DELAY', 1); //-- Refresh every 20 mins
 define ('TWITTER_PULL_EMPTY_MESSAGE', 'No Tweets');
 define ('TWITTER_PULL_CACHE_TABLE', 'cache_pulled_tweets');

@@ -22,6 +23,10 @@ function twitter_pull_empty_message() {
   return variable_get('twitter_pull_empty_message', TWITTER_PULL_EMPTY_MESSAGE);
 }

+function twitter_pull_refresh_delay() {
+  return variable_get('twitter_pull_refresh_delay', TWITTER_PULL_REFRESH_DELAY);
+}
+
 /**
  * Implements hook_menu().
  */
@@ -41,7 +46,7 @@ function twitter_pull_menu() {
  * Implements hook_flush_caches().
  */
 function twitter_pull_flush_caches() {
-  return array(TWITTER_PULL_CACHE_TABLE);
+  cache_clear_all(NULL, TWITTER_PULL_CACHE_TABLE);
 }

 /**
@@ -161,16 +166,25 @@ function twitter_pull_retrieve($twitkey, $num_items = NULL, $rts = NULL, $exclud

   $tweets = array();

-  if (!empty($cache) && !empty($cache->data) && (time() < $cache->expire)) {
-    $tweets =  $cache->data;
-  }
-  else {
+  $refresh_delay = twitter_pull_refresh_delay();
+  $refresh = $refresh_delay && ($cache->created < (time() - ($refresh_delay * 60)));
+  if (empty($cache) || empty($cache->data) || $refresh) {
     try {
       $puller = new twitter_puller($twitkey, $num_items);
-      $puller->rts = $rts;
-      $puller->exclude_replies = $exclude_replies;
       $puller->get_items();
       $tweets = $puller->tweets;
+      // Pad out tweets with items from the cache
+      if (($count = ($num_items - count($tweets))) && $cache->data) {
+        $i = 0;
+        $tweet_ids = array_map('twitter_pull_map_ids', $tweets);
+        while ($count > 0 && $i < count($cache->data)) {
+          if (!in_array($cache->data[$i]->id, $tweet_ids)) {
+            $tweets[] = $cache->data[$i];
+            $count--;
+          }
+          $i++;
+        }
+      }
     }
     catch (Exception $e) {
       watchdog('Twitter Pull', $e->getMessage(), array(), WATCHDOG_WARNING);
@@ -183,8 +197,17 @@ function twitter_pull_retrieve($twitkey, $num_items = NULL, $rts = NULL, $exclud
     }

     if (!empty($tweets) && is_array($tweets)) {
-      $cache_length = twitter_pull_cache_length() * 60; //-- in the settings we indicate length in minutes, here we need seconds.
-      cache_set($cache_key, $tweets, TWITTER_PULL_CACHE_TABLE, REQUEST_TIME + $cache_length);
+      if ($cache_length = twitter_pull_cache_length()) {
+        $cache_length *= 60;
+        $cache_length += time();
+      }
+      else {
+        $cache_length = CACHE_PERMANENT;
+      }
+      cache_set($cache_key, $tweets, TWITTER_PULL_CACHE_TABLE, $cache_length);
+    }
+    else {
+      $tweets = $cache->data;
     }
   }

@@ -199,6 +222,10 @@ function twitter_pull_retrieve($twitkey, $num_items = NULL, $rts = NULL, $exclud
   return $tweets;
 }

+function twitter_pull_map_ids($cached_data) {
+  return $cached_data->id;
+}
+
 /**
  * Automatically add links to URLs and Twitter usernames in a tweet.
  */
