diff --git a/panels_hash_cache.drush.inc b/panels_hash_cache.drush.inc
index 3cb8a62..6cdbae7 100644
--- a/panels_hash_cache.drush.inc
+++ b/panels_hash_cache.drush.inc
@@ -1,14 +1,17 @@
 <?php
 
+/**
+ * @file
+ * Drush integration for the Panels Hash Cache module.
+ */
 
 /**
- * Implementation of hook_drush_cache_clear().
+ * Implements hook_drush_cache_clear().
  */
- 
- function panels_hash_cache_drush_cache_clear(&$types) { 
+function panels_hash_cache_drush_cache_clear(&$types) {
   $types['panels hash cache'] = 'panels_hash_cache_clear';
- }
-  
- function panels_hash_cache_clear() {
-  cache_clear_all('panels-hash-cache','panels_hash_cache',TRUE); 
- }
+}
+
+function panels_hash_cache_clear() {
+  cache_clear_all('panels-hash-cache', 'panels_hash_cache', TRUE);
+}
diff --git a/panels_hash_cache.install b/panels_hash_cache.install
index b96c8ec..0a7b7b9 100644
--- a/panels_hash_cache.install
+++ b/panels_hash_cache.install
@@ -1,9 +1,14 @@
 <?php
 
 /**
- * Implementation of hook_schemea
+ * @file
+ * Install, update and uninstall functions for the Panels Hash Cache module.
+ */
+
+/**
+ * Implements hook_schema().
  */
 function panels_hash_cache_schema() {
   $schema['panels_hash_cache'] = drupal_get_schema_unprocessed('system', 'cache');
-  return $schema; 
+  return $schema;
 }
diff --git a/panels_hash_cache.module b/panels_hash_cache.module
index 59265c8..1189b95 100644
--- a/panels_hash_cache.module
+++ b/panels_hash_cache.module
@@ -3,21 +3,21 @@
 /**
  * @file
  * Hash Cash plugins for Panels.
- * 
+ *
  * Copyright (c) 2010-2011 Board of Trustees, Leland Stanford Jr. University
  * This software is open-source licensed under the GNU Public License Version 2 or later
  * The full license is available at http://www.gnu.org/licenses/gpl-2.0.html
  */
 
 /**
- * Implementation of hook_ctools_plugin_directory().
+ * Implements hook_ctools_plugin_directory().
  */
 function panels_hash_cache_ctools_plugin_directory($module, $plugin) {
   return 'plugins/' . $plugin;
 }
 
 /**
- * Implementation of hook_menu().
+ * Implements hook_menu().
  */
 function panels_hash_cache_menu() {
   $items = array();
@@ -32,15 +32,15 @@ function panels_hash_cache_menu() {
   return $items;
 }
 
-function panels_hash_cache_admin_settings(){
+function panels_hash_cache_admin_settings() {
   $form = array();
   $form['panels_hash_cache_reset_key'] = array(
-	  '#type' => 'textfield',
-		'#title' => 'Reset Key',
-		'#default_value' => variable_get('panels_hash_cache_reset_key', ''),
-		'#description' => t('Optionally allow us to regenerate the cache from the URL using a key by hitting the page with the query "?panels-hash-cache-reset={key}". This lets us, for example, to automatically re-generate a cache using cron hitting a url. This way users never see uncached content.'),
+    '#type' => 'textfield',
+    '#title' => 'Reset Key',
+    '#default_value' => variable_get('panels_hash_cache_reset_key', ''),
+    '#description' => t('Optionally allow us to regenerate the cache from the URL using a key by hitting the page with the query "?panels-hash-cache-reset={key}". This lets us, for example, to automatically re-generate a cache using cron hitting a url. This way users never see uncached content.'),
   );
-	$form = system_settings_form($form);
+  $form = system_settings_form($form);
   return $form;
 }
 
diff --git a/plugins/cache/panels_hash_cache.inc b/plugins/cache/panels_hash_cache.inc
index b18e723..56e5f05 100644
--- a/plugins/cache/panels_hash_cache.inc
+++ b/plugins/cache/panels_hash_cache.inc
@@ -1,10 +1,9 @@
 <?php
-// $Id: simple.inc,v 1.1.2.5 2011/01/07 20:59:09 merlinofchaos Exp $
 
 /**
  * @file
  * Provides hash caching for panels
- * 
+ *
  * Copyright (c) 2010-2011 Board of Trustees, Leland Stanford Jr. University
  * This software is open-source licensed under the GNU Public License Version 2 or later
  * The full license is available at http://www.gnu.org/licenses/gpl-2.0.html
@@ -34,19 +33,25 @@ function panels_hash_cache_get_cache($conf, $display, $args, $contexts, $pane =
   // hitting a url. This way users never see uncached content.
   if ($key = variable_get('panels_hash_cache_reset_key', FALSE)) {
     if (isset($_GET['panels-hash-cache-reset']) && $_GET['panels-hash-cache-reset'] == $key) {
-     return FALSE;
+      return FALSE;
     }
   }
-  
+
   $cid = panels_hash_cache_get_id($conf, $display, $args, $contexts, $pane);
-  
+
   $cache = cache_get($cid, 'panels_hash_cache');
-  
+
   // Check to see if cache missed, is empty, or is expired
-  if (!$cache) return FALSE;
-  if (empty($cache->data)) return FALSE;
-  if ((time() - $cache->created) > $conf['lifetime']) return FALSE;
-  
+  if (!$cache) {
+    return FALSE;
+  }
+  if (empty($cache->data)) {
+    return FALSE;
+  }
+  if ((REQUEST_TIME - $cache->created) > $conf['lifetime']) {
+    return FALSE;
+  }
+
   return $cache->data;
 }
 
@@ -56,7 +61,7 @@ function panels_hash_cache_get_cache($conf, $display, $args, $contexts, $pane =
 function panels_hash_cache_set_cache($conf, $content, $display, $args, $contexts, $pane = NULL) {
   if (!empty($content)) {
     $cid = panels_hash_cache_get_id($conf, $display, $args, $contexts, $pane);
-    cache_set($cid, $content,'panels_hash_cache');
+    cache_set($cid, $content, 'panels_hash_cache');
   }
 }
 
@@ -82,7 +87,7 @@ function panels_hash_cache_clear_cache($display) {
  */
 function panels_hash_cache_get_id($conf, $display, $args, $contexts, $pane) {
   $id = 'panels-hash-cache';
-  
+
   // This is used in case this is an in-code display, which means did will be something like 'new-1'.
   if (isset($display->owner) && isset($display->owner->id)) {
     $id .= '-' . $display->owner->id;
@@ -93,7 +98,7 @@ function panels_hash_cache_get_id($conf, $display, $args, $contexts, $pane) {
   elseif (isset($display->css_id)) {
     $id .= '-' . $display->css_id;
   }
-  
+
   if ($pane) {
     $id .= '-' . $pane->pid;
   }
@@ -101,11 +106,11 @@ function panels_hash_cache_get_id($conf, $display, $args, $contexts, $pane) {
   if (user_access('view pane admin links')) {
     $id .= '-admin';
   }
-  
+
   // For each selected ganularity situation, add it to the "hashable-string"
   // This hashable string becomes our cache-key (after it's hashed to shorten it)
   $hashable_string = '';
-  
+
   if ($conf['granularity']['args']) {
     foreach ($args as $arg) {
       $hashable_string .= $arg;
@@ -122,45 +127,45 @@ function panels_hash_cache_get_id($conf, $display, $args, $contexts, $pane) {
   if ($conf['granularity']['path']) {
     $hashable_string .= implode('/', arg());
   }
-  
+
   if ($conf['granularity']['url']) {
-    $url = parse_url('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
-    
+    $url = parse_url('http://' . $_SERVER['HTTP_HOST'] . request_uri());
+
     // If panels-hash-cache-reset is set, then unset it from the query to hash
     if (isset($_GET['panels-hash-cache-reset']) && $key = $_GET['panels-hash-cache-reset']) {
-      $url['query'] = str_replace('panels-hash-cache-reset='.$key,'',$url['query']);
-      $url['query'] = trim($url['query'],"&");
+      $url['query'] = str_replace('panels-hash-cache-reset=' . $key, '', $url['query']);
+      $url['query'] = trim($url['query'], "&");
     }
-    
-    $hashable_string = $url['host'].$url['path'];
-    if(!empty($url['query'])) {
+
+    $hashable_string = $url['host'] . $url['path'];
+    if (!empty($url['query'])) {
       $hashable_string .= $url['query'];
     }
   }
-  
+
   if ($conf['granularity']['user']) {
     // For the user we hash on their UID, username, email and roles. In D7 we will have an "updated" timestamp to hash on
     global $user;
-    $hashable_string .= $user->uid.$user->name.$user->mail.serialize($user->roles);
+    $hashable_string .= $user->uid . $user->name . $user->mail . serialize($user->roles);
   }
   if ($conf['granularity']['user_role']) {
     global $user;
     $hashable_string .= serialize($user->roles);
   }
-  
+
   if ($hashable_string) {
-    $id .= '-'.sha1($hashable_string);
+    $id .= '-' . sha1($hashable_string);
   }
-  
+
   if (module_exists('locale')) {
     global $language;
     $id .= '-' . $language->language;
   }
-  
-  if(isset($pane->configuration['use_pager']) && $pane->configuration['use_pager'] == 1) {
+
+  if (isset($pane->configuration['use_pager']) && $pane->configuration['use_pager'] == 1) {
     $id .= '-p' . check_plain($_GET['page']);
   }
-  
+
   return $id;
 }
 
@@ -188,7 +193,6 @@ function panels_hash_cache_settings_form($conf, $display, $pid) {
     '#description' => t('The methods in which you wish to store and expire the cache. A change in any of these things will result in a new cache being generated. If more than one is selected, a unique cache will be created for that combination and the cache expires upon a change if any of the components.'),
     '#default_value' => $conf['granularity'],
   );
-  
+
   return $form;
 }
-
