diff --git a/XHProfRunsFile.inc b/XHProfRunsFile.inc
index 9774ed0..c04f1a8 100644
--- a/XHProfRunsFile.inc
+++ b/XHProfRunsFile.inc
@@ -1,6 +1,11 @@
 <?php
 
 /**
+ * @file
+ * Definition of XHProfRunsFile.
+ */
+
+/**
  * XHProfRuns_Default is the default implementation of the
  * iXHProfRuns interface for saving/fetching XHProf runs.
  *
@@ -9,7 +14,7 @@ class XHProfRunsFile implements XHProfRunsInterface {
   private $dir = '';
   private $suffix = 'xhprof';
 
-  public function getDir(){
+  public function getDir() {
     return $this->dir;
   }
 
@@ -27,7 +32,7 @@ class XHProfRunsFile implements XHProfRunsInterface {
     return $file;
   }
 
-  public function __construct($dir = null) {
+  public function __construct($dir = NULL) {
     // if user hasn't passed a directory location,
     // we use the xhprof.output_dir ini setting
     // if specified, else we default to the directory
@@ -37,10 +42,10 @@ class XHProfRunsFile implements XHProfRunsInterface {
       if (empty($dir)) {
         // some default that at least works on unix...
         $dir = "/tmp";
-        watchdog("xhprof", "Warning: Must specify directory location for XHProf runs. ".
+        watchdog("xhprof", "Warning: Must specify directory location for XHProf runs. " .
                      "Trying {$dir} as default. You can either pass the " .
-                     "directory location as an argument to the constructor ".
-                     "for XHProfRuns_Default() or set xhprof.output_dir ".
+                     "directory location as an argument to the constructor " .
+                     "for XHProfRuns_Default() or set xhprof.output_dir " .
                      "ini param.");
       }
     }
@@ -53,7 +58,7 @@ class XHProfRunsFile implements XHProfRunsInterface {
     if (!file_exists($file_name)) {
       watchdog("xhprof", "Could not find file $file_name");
       $run_desc = "Invalid Run Id = $run_id";
-      return null;
+      return NULL;
     }
 
     $contents = file_get_contents($file_name);
@@ -61,13 +66,13 @@ class XHProfRunsFile implements XHProfRunsInterface {
     return unserialize($contents);
   }
 
-  public function save_run($xhprof_data, $type, $run_id = null) {
+  public function save_run($xhprof_data, $type, $run_id = NULL) {
 
     // Use PHP serialize function to store the XHProf's
     // raw profiler data.
     $xhprof_data = serialize($xhprof_data);
 
-    if ($run_id === null) {
+    if ($run_id === NULL) {
       $run_id = $this->gen_run_id($type);
     }
 
@@ -95,7 +100,7 @@ class XHProfRunsFile implements XHProfRunsInterface {
     return $files;
   }
 
-  public function getCount(){}
+  public function getCount() {}
 
   public function scanXHProfDir($dir, $source = NULL) {
     if (is_dir($dir)) {
diff --git a/XHProfRunsInterface.inc b/XHProfRunsInterface.inc
index 3a9e18b..3f4af77 100644
--- a/XHProfRunsInterface.inc
+++ b/XHProfRunsInterface.inc
@@ -1,5 +1,10 @@
 <?php
 
+/**
+ * @file
+ * Definition of XHProfRunsInterace.
+ */
+
 interface XHProfRunsInterface {
   /**
   * This function gets runs based on passed parameters, column data as key, value as the value. Values
@@ -12,6 +17,6 @@ interface XHProfRunsInterface {
   public function getRuns($stats, $limit = 50, $skip = 0);
   public function getCount();
   public function get_run($run_id, $type, &$run_desc);
-  public function save_run($xhprof_data, $type, $run_id = null);
+  public function save_run($xhprof_data, $type, $run_id = NULL);
 }
 
diff --git a/modules/xhprof_mongodb/MongodbXHProfRuns.inc b/modules/xhprof_mongodb/MongodbXHProfRuns.inc
index 05e20fe..88556d9 100644
--- a/modules/xhprof_mongodb/MongodbXHProfRuns.inc
+++ b/modules/xhprof_mongodb/MongodbXHProfRuns.inc
@@ -1,5 +1,13 @@
 <?php
 
+/**
+ * @file
+ * Definition of MongodbXHProfRuns.
+ */
+
+/**
+ * Defines a MongoDB storage backend for XHProf.
+ */
 class MongodbXHProfRuns implements XHProfRunsInterface {
 
   private $dir = '';
@@ -17,7 +25,7 @@ class MongodbXHProfRuns implements XHProfRunsInterface {
     return $file;
   }
 
-  public function __construct($dir = null) {
+  public function __construct($dir = NULL) {
   }
 
   /**
@@ -66,8 +74,8 @@ class MongodbXHProfRuns implements XHProfRunsInterface {
     return $run['run_data'];
   }
 
-  public function save_run($xhprof_data, $type, $run_id = null) {
-    if ($run_id === null) {
+  public function save_run($xhprof_data, $type, $run_id = NULL) {
+    if ($run_id === NULL) {
       $run_id = $this->gen_run_id($type);
     }
 
diff --git a/modules/xhprof_mongodb/xhprof_mongodb.info b/modules/xhprof_mongodb/xhprof_mongodb.info
index df44b01..74b3cf6 100644
--- a/modules/xhprof_mongodb/xhprof_mongodb.info
+++ b/modules/xhprof_mongodb/xhprof_mongodb.info
@@ -1,4 +1,3 @@
-; $Id:
 name = XHProf MongoDB
 description = UI for xhprof runs.
 package = Development
diff --git a/modules/xhprof_mongodb/xhprof_mongodb.install b/modules/xhprof_mongodb/xhprof_mongodb.install
index e49a141..bf53fa0 100644
--- a/modules/xhprof_mongodb/xhprof_mongodb.install
+++ b/modules/xhprof_mongodb/xhprof_mongodb.install
@@ -1,5 +1,13 @@
 <?php
 
+/**
+ * @file
+ * Install, update and uninstall functions for the XHProf module.
+ */
+ 
+/**
+ * Implementation of hook_install().
+ */
 function xhprof_mongodb_install() {
   module_load_include('module', 'mongodb');
   $collection = mongodb_collection('xhprof');
diff --git a/xhprof.admin.inc b/xhprof.admin.inc
index a556954..9009100 100755
--- a/xhprof.admin.inc
+++ b/xhprof.admin.inc
@@ -1,5 +1,13 @@
 <?php
 
+/**
+ * @file
+ * Admin page callbacks for the XHProf module.
+ */
+
+/**
+ * Administrative settings form for XHProf module.
+ */
 function xhprof_admin_settings() {
   $description = extension_loaded('xhprof') ? t('Profile requests with the xhprof php extension.') : '<span class="warning">' . t('You must enable the <a href="!url">xhprof php extension</a> to use this feature.', array('!url' => url('http://techportal.ibuildings.com/2009/12/01/profiling-with-xhprof/'))) . '</span>';
   $form['xhprof_enabled'] = array(
diff --git a/xhprof.inc b/xhprof.inc
index 8b55605..e0362db 100755
--- a/xhprof.inc
+++ b/xhprof.inc
@@ -10,10 +10,10 @@ define('XHPROF_BOOL_PARAM',   4);
 $sort_col = "wt";
 
 // default is "single run" report
-$diff_mode = false;
+$diff_mode = FALSE;
 
 // call count data present?
-$display_calls = true;
+$display_calls = TRUE;
 
 function xhprof_sortable_columns() {
 // The following column headers are sortable
@@ -178,7 +178,7 @@ $totals_2 = 0;
 /*
  * The subset of $possible_metrics that is present in the raw profile data.
  */
-$metrics = null;
+$metrics = NULL;
 
 
 //  Copyright (c) 2009 Facebook
@@ -213,7 +213,7 @@ $base_path = rtrim(dirname($_SERVER['SCRIPT_NAME']), "/");
  * can be specified in the generated HTML.
  *
  */
-function xhprof_xhprof_include_js_css($ui_dir_url_path = null) {
+function xhprof_xhprof_include_js_css($ui_dir_url_path = NULL) {
 
   if (empty($ui_dir_url_path)) {
     $ui_dir_url_path = rtrim(dirname($_SERVER['SCRIPT_NAME']), "/");
@@ -402,7 +402,7 @@ function xhprof_sort_cbk($a, $b) {
  *
  * @author Kannan
  */
-function xhprof_init_metrics($xhprof_data, $rep_symbol, $sort, $diff_report = false) {
+function xhprof_init_metrics($xhprof_data, $rep_symbol, $sort, $diff_report = FALSE) {
   global $stats;
   global $pc_stats;
   global $metrics;
@@ -434,10 +434,10 @@ function xhprof_init_metrics($xhprof_data, $rep_symbol, $sort, $diff_report = fa
     // is present for "main()". But currently "ct"
     // metric is artificially set to 1. So, relying
     // on absence of "wt" metric instead.
-    $display_calls = false;
+    $display_calls = FALSE;
   }
   else {
-    $display_calls = true;
+    $display_calls = TRUE;
   }
 
   // parent/child report doesn't support exclusive times yet.
@@ -677,8 +677,8 @@ function xhprof_profiler_report($url_params, $rep_symbol, $sort, $run1, $run1_de
 
     // Single function xhprof_report with parent/child information.
     if ($diff_mode) {
-      $info1 = isset($symbol_tab1[$rep_symbol]) ? $symbol_tab1[$rep_symbol] : null;
-      $info2 = isset($symbol_tab2[$rep_symbol]) ? $symbol_tab2[$rep_symbol] : null;
+      $info1 = isset($symbol_tab1[$rep_symbol]) ? $symbol_tab1[$rep_symbol] : NULL;
+      $info2 = isset($symbol_tab2[$rep_symbol]) ? $symbol_tab2[$rep_symbol] : NULL;
       $output .= xhprof_symbol_report($url_params, $run_delta, $symbol_tab[$rep_symbol], $sort, $rep_symbol,
                                          $run1, $info1, $run2, $info2);
     }
@@ -968,11 +968,11 @@ function xhprof_full_report($url_params, $symbol_tab, $sort, $run1, $run2) {
   $output .= "<br>";
 
   if (!empty($url_params['all'])) {
-    $all = true;
+    $all = TRUE;
     $limit = 0;    // display all rows
   }
   else {
-    $all = false;
+    $all = FALSE;
     $limit = 100;  // display only limited number of rows
   }
 
@@ -1100,7 +1100,7 @@ function xhprof_print_symbol_summary($symbol_info, $stat, $base) {
  * @author Kannan
  */
 function xhprof_symbol_report($url_params, $run_data, $symbol_info, $sort, $rep_symbol, $run1,
-                                 $symbol_info1 = null, $run2 = 0, $symbol_info2 = null) {
+                                 $symbol_info1 = NULL, $run2 = 0, $symbol_info2 = NULL) {
   global $vwbar;
   global $vbar;
   global $totals;
@@ -1144,8 +1144,8 @@ function xhprof_symbol_report($url_params, $run_data, $symbol_info, $sort, $rep_
       $output .= "<td>Number of function xhprof_Calls</td>";
       $output .= xhprof_print_num($symbol_info1["ct"], $format_cbk["ct"]);
       $output .= xhprof_print_num($symbol_info2["ct"], $format_cbk["ct"]);
-      $output .= xhprof_print_num($symbol_info2["ct"] - $symbol_info1["ct"], $format_cbk["ct"], true);
-      $output .= xhprof_print_pct($symbol_info2["ct"] - $symbol_info1["ct"], $symbol_info1["ct"], true);
+      $output .= xhprof_print_num($symbol_info2["ct"] - $symbol_info1["ct"], $format_cbk["ct"], TRUE);
+      $output .= xhprof_print_pct($symbol_info2["ct"] - $symbol_info1["ct"], $symbol_info1["ct"], TRUE);
       $output .= '</tr>';
     }
 
@@ -1157,8 +1157,8 @@ function xhprof_symbol_report($url_params, $run_data, $symbol_info, $sort, $rep_
       $output .= "<td>" . str_replace("<br>", " ", $descriptions[$m]) . "</td>";
       $output .= xhprof_print_num($symbol_info1[$m], $format_cbk[$m]);
       $output .= xhprof_print_num($symbol_info2[$m], $format_cbk[$m]);
-      $output .= xhprof_print_num($symbol_info2[$m] - $symbol_info1[$m], $format_cbk[$m], true);
-      $output .= xhprof_print_pct($symbol_info2[$m] - $symbol_info1[$m], $symbol_info1[$m], true);
+      $output .= xhprof_print_num($symbol_info2[$m] - $symbol_info1[$m], $format_cbk[$m], TRUE);
+      $output .= xhprof_print_pct($symbol_info2[$m] - $symbol_info1[$m], $symbol_info1[$m], TRUE);
       $output .= '</tr>';
 
       // AVG (per call) Inclusive stat for metric
@@ -1272,7 +1272,7 @@ function xhprof_symbol_report($url_params, $run_data, $symbol_info, $sort, $rep_
   usort($results, 'xhprof_sort_cbk');
 
   if (count($results) > 0) {
-    $pc_row = xhprof_print_pc_array($url_params, $results, $base_ct, $base_info, true, $run1, $run2);
+    $pc_row = xhprof_print_pc_array($url_params, $results, $base_ct, $base_info, TRUE, $run1, $run2);
     $rows = array_merge($rows, $pc_row);
   }
 
@@ -1293,7 +1293,7 @@ function xhprof_symbol_report($url_params, $run_data, $symbol_info, $sort, $rep_
   usort($results, 'xhprof_sort_cbk');
 
   if (count($results)) {
-    $pc_row = xhprof_print_pc_array($url_params, $results, $base_ct, $base_info, false, $run1, $run2);
+    $pc_row = xhprof_print_pc_array($url_params, $results, $base_ct, $base_info, FALSE, $run1, $run2);
     $rows = array_merge($rows, $pc_row);
   }
 
@@ -1313,9 +1313,9 @@ function xhprof_symbol_report($url_params, $run_data, $symbol_info, $sort, $rep_
   $output .= "var metrics_col  = new Array();\n";
   $output .= "var metrics_desc  = new Array();\n";
   if ($diff_mode) {
-    $output .= "var diff_mode = true;\n";
+    $output .= "var diff_mode = TRUE;\n";
   } else {
-    $output .= "var diff_mode = false;\n";
+    $output .= "var diff_mode = FALSE;\n";
   }
   $column_index = 3; // First three columns are Func Name, Calls, Calls%
   foreach ($metrics as $metric) {
@@ -1340,7 +1340,7 @@ function xhprof_symbol_report($url_params, $run_data, $symbol_info, $sort, $rep_
 function xhprof_profiler_single_run_report ($url_params, $xhprof_data, $run_desc, $rep_symbol, $sort, $run) {
   $output = '';
 
-  xhprof_init_metrics($xhprof_data, $rep_symbol, $sort, false);
+  xhprof_init_metrics($xhprof_data, $rep_symbol, $sort, FALSE);
   $output .= xhprof_profiler_report($url_params, $rep_symbol, $sort, $run, $run_desc, $xhprof_data);
   return $output;
 }
@@ -1365,7 +1365,7 @@ function xhprof_profiler_single_run_report ($url_params, $xhprof_data, $run_desc
 //
 //  $output = '';
 //  // Initialize what metrics we'll display based on data in Run2
-//  $output .= xhprof_init_metrics($xhprof_data2, $rep_symbol, $sort, true);
+//  $output .= xhprof_init_metrics($xhprof_data2, $rep_symbol, $sort, TRUE);
 //
 //  $output .= xhprof_profiler_report($url_params,
 //                  $rep_symbol,
@@ -1435,9 +1435,9 @@ function xhprof_displayXHProfReport($xhprof_runs_impl, $options) {
         $wts_array  = explode(",", $wts);
       }
       else {
-        $wts_array = null;
+        $wts_array = NULL;
       }
-      $data = xhprof_aggregate_runs($xhprof_runs_impl, $runs_array, $wts_array, $source, false);
+      $data = xhprof_aggregate_runs($xhprof_runs_impl, $runs_array, $wts_array, $source, FALSE);
       $xhprof_data = $data['raw'];
       $description = $data['description'];
     }
@@ -1596,7 +1596,7 @@ function xhprof_parse_parent_child($parent_child) {
     return $ret;
   }
 
-  return array(null, $ret[0]);
+  return array(NULL, $ret[0]);
 }
 
 
diff --git a/xhprof.module b/xhprof.module
index cf5cd49..592cb32 100644
--- a/xhprof.module
+++ b/xhprof.module
@@ -1,5 +1,6 @@
 <?php
-require_once(dirname(__FILE__) .'/xhprof.inc');
+
+require_once(dirname(__FILE__) . '/xhprof.inc');
 
 define('XHPROF_PATH', 'admin/reports/xhprof');
 
@@ -46,7 +47,7 @@ function xhprof_menu() {
 
 
 /**
- * Implement hook_permission().
+ * Implementation of hook_permission().
  */
 function xhprof_permission() {
   return array(
@@ -71,7 +72,7 @@ function xhprof_theme() {
 }
 
 /**
- * Implements hook_views_api().
+ * Implementation of hook_views_api().
  */
 function xhprof_views_api() {
   return array(
@@ -80,6 +81,9 @@ function xhprof_views_api() {
   );
 }
 
+/**
+ * Conditionally enable XHProf profiling.
+ */
 function xhprof_xhprof_enable() {
   if (xhprof_is_enabled()) {
     // @todo: consider a variable per-flag instead.
@@ -91,6 +95,9 @@ function xhprof_xhprof_enable() {
   }
 }
 
+/**
+ * Check whether XHProf should be enabled for the current request.
+ */
 function xhprof_is_enabled() {
   $enabled = FALSE;
   if (extension_loaded('xhprof') && variable_get('xhprof_enabled', FALSE)) {
@@ -165,7 +172,7 @@ function xhprof_shutdown_xhprof() {
 function xhprof_link($run_id, $type = 'link') {
   $namespace = variable_get('site_name', '');  // namespace for your application
   $url  = base_path() . XHPROF_PATH . '/' . $run_id;
-  return $type == 'url' ? $url : t('<a href="@xhprof">XHProf output</a>. ', array('@xhprof' => $url));
+  return $type == 'url' ? $url : t('<a href="@xhprof">XHProf output</a>.', array('@xhprof' => $url)) . ' ';
 }
 
 /**
@@ -190,12 +197,15 @@ function _xhprof_get_object() {
       $xhprof_object = new $class();
     }
     else {
-      watchdog('xhprof', t('Unable to load default class %class!'), array('%class' => $class), WATCHDOG_CRITICAL);
+      watchdog('xhprof', 'Unable to load default class %class!', array('%class' => $class), WATCHDOG_CRITICAL);
     }
   }
   return $xhprof_object;
 }
 
+/**
+ * List all available XHProf storage backends.
+ */
 function xhprof_get_classes() {
   xhprof_include();
   $classes = array('XHProfRunsFile');
@@ -203,6 +213,9 @@ function xhprof_get_classes() {
   return $classes;
 }
 
+/**
+ * Display list of saved XHProf runs.
+ */
 function xhprof_run_list() {
   global $pager_page_array, $pager_total, $pager_total_items;
   xhprof_include();
@@ -246,6 +259,9 @@ function xhprof_run_list() {
   return $output;
 }
 
+/**
+ * Get default URL parameters for XHProf.
+ */
 function xhprof_param_defaults() {
   // param name, its type, and default value
   return array(
@@ -260,16 +276,25 @@ function xhprof_param_defaults() {
   );
 }
 
+/**
+ * Page callback to display a XHProf run.
+ */
 function xhprof_display_page($run_id, $symbol = NULL) {
   drupal_add_css(drupal_get_path('module', 'xhprof') . '/xhprof.css');
   return xhprof_display_run(array($run_id), $symbol);
 }
 
+/**
+ * Page callback to display a difference of two XHProf runs.
+ */
 function xhprof_display_diff_page($run1, $run2, $symbol = NULL) {
   drupal_add_css(drupal_get_path('module', 'xhprof') . '/xhprof.css');
   return xhprof_display_run(array($run1, $run2), $symbol = NULL);
 }
 
+/**
+ * Display XHProf run report.
+ */
 function xhprof_display_run($run_ids, $symbol = NULL) {
   if (count($run_ids) === 1) {
     $_GET['run'] = $run_ids[0];
@@ -319,13 +344,13 @@ function xhprof_display_run($run_ids, $symbol = NULL) {
         $wts_array  = explode(",", $wts);
       }
       else {
-        $wts_array = null;
+        $wts_array = NULL;
       }
-      $data = xhprof_aggregate_runs($xhprof_runs_impl, $runs_array, $wts_array, $source, false);
+      $data = xhprof_aggregate_runs($xhprof_runs_impl, $runs_array, $wts_array, $source, FALSE);
       $xhprof_data = $data['raw'];
       $description = $data['description'];
     }
-    xhprof_init_metrics($xhprof_data, $symbol, $sort, false);
+    xhprof_init_metrics($xhprof_data, $symbol, $sort, FALSE);
     $output .= xhprof_profiler_report($url_params, $symbol, $sort, $run_id, $description, $xhprof_data);
   }
   elseif ($run1 && $run2) {
@@ -333,7 +358,7 @@ function xhprof_display_run($run_ids, $symbol = NULL) {
     $xhprof_data1 = $xhprof_runs_impl->get_run($run1, $source, $description1);
     $xhprof_data2 = $xhprof_runs_impl->get_run($run2, $source, $description2);
     // Initialize what metrics we'll display based on data in Run2
-    $output .= xhprof_init_metrics($xhprof_data2, $symbol, $sort, true);
+    $output .= xhprof_init_metrics($xhprof_data2, $symbol, $sort, TRUE);
     $output .= xhprof_profiler_report($url_params, $symbol, $sort, $run1, $description1, $xhprof_data1, $run2, $description2, $xhprof_data2);
   }
   else {
@@ -347,7 +372,7 @@ function xhprof_scandir($dir, $source) {
   if (is_dir($dir)) {
     $runs = array();
     foreach (glob("$dir/*.$source") as $file) {
-      list($run,$source) = explode('.', basename($file));
+      list($run, $source) = explode('.', basename($file));
       $runs[] = array(
         'run_id' => $run,
         'source' => $source,
@@ -359,13 +384,16 @@ function xhprof_scandir($dir, $source) {
   return array_reverse($runs);
 }
 
+/**
+ * Theme function to display XHProf run summary.
+ */
 function theme_xhprof_overall_summary($variables) {
   $output = '';
   // Extract variables: $totals, $possible_metrics, $metrics, $display_calls;
   extract($variables);
   $rows = array();
   foreach ($metrics as $metric) {
-    $rows[] = array('<strong>Total ' . xhprof_stat_description($metric) . ':</strong>', number_format($totals[$metric]) .  " " . $possible_metrics[$metric][1]);
+    $rows[] = array('<strong>Total ' . xhprof_stat_description($metric) . ':</strong>', number_format($totals[$metric]) . " " . $possible_metrics[$metric][1]);
   }
 
   if ($display_calls) {
@@ -376,6 +404,9 @@ function theme_xhprof_overall_summary($variables) {
   return $output;
 }
 
+/**
+ * Theme function to display list of XHProf function calls.
+ */
 function theme_xhprof_run_table($variables) {
   // Extract variables: $stats, $totals, $url_params, $title, $flat_data, $limit.
   extract($variables);
