diff --git a/includes/biblio.pages.inc b/includes/biblio.pages.inc
index dd6e93d..8ce17ac 100644
--- a/includes/biblio.pages.inc
+++ b/includes/biblio.pages.inc
@@ -11,7 +11,8 @@
  *   Integer ID of the node which the page request will be changed to view.
  */
 function biblio_view_node($nid) {
-  drupal_goto('node/'.(int) $nid, NULL, NULL, 301); // set a 301 response code
+  // Set a 301 response code.
+  drupal_goto('node/' . (int) $nid, NULL, NULL, 301);
 }
 
 /**
@@ -44,7 +45,7 @@ function biblio_db_search() {
   // biblio_db_search('search', 'bla blu')
   $search = array_search('search', $arg_list);
   if ($search !== FALSE) {
-    $keys = $arg_list[$search+1];
+    $keys = $arg_list[$search + 1];
 
     // Special case: if search is activated via URL, i.e., biblio/search/...,
     // we reset the search session filter. Two searches are not combinable.
@@ -67,12 +68,14 @@ function biblio_db_search() {
           $node_list .= $nid . ",";
         }
         // No node search result. Make sure we find nothing, too. Node -1 does not exist.
-        if (empty($node_list)) $node_list = '-1';
+        if (empty($node_list)) {
+          $node_list = '-1';
+        }
 
         // Store as SESSION filter or argument list.
         // When called as function argument it takes only one parameter, i.e.
         // biblio_db_search('search', 'bla blu') and we must insert the node
-        // list inbetween.
+        // list in between.
         if ($search !== FALSE) {
           array_splice($arg_list, $search + 1, 0, $node_list);
         }
@@ -116,7 +119,7 @@ function biblio_db_search() {
 }
 
 /**
- * Creates an SQL query to select and order biblio type content.
+ * Creates an SQL query string to select and order biblio type content.
  *
  * biblio_db_search builds the SQL query which will be used to
  * select and order "biblio" type nodes.  The query results are
@@ -147,22 +150,24 @@ function biblio_build_query($arg_list) {
   $selects = array();
   $count_selects = array();
   $count_limit = '';
+  $sort_attrib = array();
+  $terms = array();
 
   $selects[] = "DISTINCT(n.nid)";
   $count_selects[] = "DISTINCT(n.nid)";
   $selects[] = "bt.name as biblio_type_name";
 
-  $joins[] = "left join {biblio} b  on n.vid=b.vid ";
-  $joins[] = "inner join {biblio_types} bt  on b.biblio_type=bt.tid ";
+  $joins[] = "LEFT JOIN {biblio} b ON n.vid=b.vid ";
+  $joins[] = "INNER JOIN {biblio_types} bt ON b.biblio_type=bt.tid ";
 
-  // POSIX regular expression matching, case insensitive
+  // POSIX regular expression matching, case insensitive.
   $match_op = ($db_type == 'pgsql') ? '~*' : 'RLIKE';
-   // The following is to be used to compare titles
-   // LOWER() is required for case insensitive sorting (at least, in PostgreSQL)
+  // The following is to be used to compare titles; LOWER() is required for case
+  // insensitive sorting (at least, in PostgreSQL).
   $sort_title = 'biblio_sort_title';
 
   $limit = '';
-  if (variable_get('biblio_view_only_own', 0) ) {
+  if (variable_get('biblio_view_only_own', 0)) {
     $limit .= " AND n.uid = $user->uid ";
   }
 
@@ -171,10 +176,9 @@ function biblio_build_query($arg_list) {
     $arg_list[] = variable_get('biblio_sort', 'year');
     $arg_list[] = 'order';
     $arg_list[] = strtolower(variable_get('biblio_order', 'desc'));
-
   }
 
-  $limits = null;
+  $limits = NULL;
 
   if (!isset($_SESSION['biblio_filter']) || !is_array($_SESSION['biblio_filter'])) {
     $_SESSION['biblio_filter'] = array();
@@ -196,6 +200,7 @@ function biblio_build_query($arg_list) {
       switch ($type) {
         case 'no_filters':
           break;
+
         case 'inline':
           $inline = TRUE;
           break;
@@ -212,8 +217,8 @@ function biblio_build_query($arg_list) {
         case 'cid':
         case 'aid':
           $bcc++;
-          $term = explode("?",array_shift($arg_list));
-          $joins[] = "inner join {biblio_contributor} as bc" . $bcc . " on n.vid = bc" . $bcc . ".vid";
+          $term = explode("?", array_shift($arg_list));
+          $joins[] = "INNER JOIN {biblio_contributor} as bc" . $bcc . " on n.vid = bc" . $bcc . ".vid";
           $where[] = "bc" . $bcc . ".cid = '%d' ";
           $terms[] = db_escape_string($term[0]);
           array_push($args, $type, $term[0]);
@@ -221,13 +226,14 @@ function biblio_build_query($arg_list) {
 
         case 'term':
         case 'term_id':
-          $term = explode("?",array_shift($arg_list));
-          $joins[] = "inner join {term_node} as tn". $tcc ." on n.vid = tn".$tcc.".vid";
+          $term = explode("?", array_shift($arg_list));
+          $joins[] = "INNER JOIN {term_node} as tn" . $tcc . " on n.vid = tn" . $tcc . ".vid";
           if ($type == 'term') {
-            $joins[] = "inner join  {term_data} as td on tn". $tcc .".tid= td.tid";
+            $joins[] = "INNER JOIN {term_data} as td on tn" . $tcc . ".tid= td.tid";
             $where[] = "td.name = '%s' ";
-          }elseif ($type == 'term_id') {
-            $where[] = "tn". $tcc .".tid = '%d' ";
+          }
+          elseif ($type == 'term_id') {
+            $where[] = "tn" . $tcc . ".tid = '%d' ";
           }
           $terms[] = db_escape_string($term[0]);
           array_push($args, $type, $term[0]);
@@ -235,16 +241,17 @@ function biblio_build_query($arg_list) {
           break;
 
         case 'tg':
-          $term = explode("?",array_shift($arg_list));
-          $where[] = "substring($sort_title,1 ,1)" . $match_op . " LOWER('%s')";
+          $term = explode("?", array_shift($arg_list));
+          $where[] = "substring($sort_title, 1 ,1)" . $match_op . " LOWER('%s')";
           $terms[] = db_escape_string($term[0]);
           array_push($args, $type, $term[0]);
           break;
 
-        case 'ag': //selects entries whoose authors firstname starts with the letter provided
-          $term = explode("?",array_shift($arg_list));
-          $where[] = " UPPER(substring(bcd.lastname,1,1)) = '%s' ";
-          //$where['bc-rank'] = "bc.rank=0";
+        case 'ag':
+          // Selects entries whose authors' firstname starts with the letter
+          // provided.
+          $term = explode("?", array_shift($arg_list));
+          $where[] = " UPPER(substring(bcd.lastname, 1, 1)) = '%s' ";
           $joins['bc'] = '  INNER JOIN {biblio_contributor} as bc on b.vid = bc.vid ';
           $joins['bcd'] = '  JOIN {biblio_contributor_data} as bcd on bc.cid = bcd.cid ';
           $terms[] = db_escape_string(strtoupper($term[0]));
@@ -253,23 +260,24 @@ function biblio_build_query($arg_list) {
 
         case 'author':
           $bcc++;
-          $term = explode("?",array_shift($arg_list));
+          $term = explode("?", array_shift($arg_list));
 
-          if (is_numeric($term[0])){
-            $joins[] = "inner join {biblio_contributor} as bc". $bcc ." on n.vid = bc". $bcc .".vid";
+          if (is_numeric($term[0])) {
+            $joins[] = "inner join {biblio_contributor} as bc" . $bcc . " on n.vid = bc" . $bcc . ".vid";
             $cids = db_query('SELECT cid FROM {biblio_contributor_data}
-                              WHERE cid = %d OR aka = (SELECT aka FROM {biblio_contributor_data} WHERE cid = %d)'
-                              ,$term[0], $term[0]);
+                              WHERE cid = %d OR aka = (SELECT aka FROM {biblio_contributor_data} WHERE cid = %d)',
+                             $term[0], $term[0]);
             $wr = '';
-            while ($cid = db_fetch_object($cids) ){
-              $wr .= empty($wr)?'':' OR ';
-              $wr .= "bc". $bcc .".cid = $cid->cid ";
+            while ($cid = db_fetch_object($cids)) {
+              $wr .= empty($wr) ? '' : ' OR ';
+              $wr .= "bc" . $bcc . ".cid = $cid->cid ";
             }
-            $where[] = (!empty($wr)) ? $wr : "bc". $bcc .".cid = -1 ";
-          }else{
-            $where[] = " bcd". $bcc .'.name '. $match_op .' "[[:<:]]%s[[:>:]]" ';
-            $joins[] = " JOIN {biblio_contributor} as bc". $bcc ." on b.vid = bc". $bcc .".vid ";
-            $joins[] = " JOIN {biblio_contributor_data} as bcd". $bcc ." on bc". $bcc .".cid = bcd".$bcc .".cid ";
+            $where[] = (!empty($wr)) ? $wr : "bc" . $bcc . ".cid = -1 ";
+          }
+          else {
+            $where[] = " bcd" . $bcc . '.name ' . $match_op . ' "[[:<:]]%s[[:>:]]" ';
+            $joins[] = " JOIN {biblio_contributor} as bc" . $bcc . " on b.vid = bc" . $bcc . ".vid ";
+            $joins[] = " JOIN {biblio_contributor_data} as bcd" . $bcc . " on bc" . $bcc . ".cid = bcd" . $bcc . ".cid ";
             $terms[] = db_escape_string($term[0]);
             $rss_info['title'] = t("Publications by " . $term[0]);
             $rss_info['description'] = t("These publications by %author are part of the works listed at %sitename", array('%author' => $term[0], '%sitename' => variable_get('site_name', 'Drupal')));
@@ -279,8 +287,8 @@ function biblio_build_query($arg_list) {
           break;
 
         case 'publisher':
-          $term = explode("?",array_shift($arg_list));
-          $where[] = "b.biblio_publisher ". $match_op ." '%s' ";
+          $term = explode("?", array_shift($arg_list));
+          $where[] = "b.biblio_publisher " . $match_op . " '%s' ";
           $terms[] = db_escape_string($term[0]);
           array_push($args, $type, $term[0]);
           break;
@@ -288,26 +296,23 @@ function biblio_build_query($arg_list) {
         case 'year':
           $term = db_escape_string(array_shift($arg_list));
           $where[] = "b.biblio_year=%d ";
-          //$limit .= " AND b.biblio_year=%d ";
-          $terms[] = (int)$term;
-          array_push($args, $type, (int)$term);
+          $terms[] = (int) $term;
+          array_push($args, $type, (int) $term);
           break;
 
         case 'uid':
           $term = db_escape_string(array_shift($arg_list));
           $where[] = "n.uid=%d ";
-          //$limit .= " AND b.biblio_year=%d ";
-          $terms[] = (int)$term;
-          array_push($args, $type, (int)$term);
+          $terms[] = (int) $term;
+          array_push($args, $type, (int) $term);
           break;
 
         case 'keyword':
           $bkd++;
-          $term = explode("?",array_shift($arg_list));
+          $term = explode("?", array_shift($arg_list));
           if (is_numeric($term[0])){
             $terms[] = db_escape_string($term[0]);
-            $joins[] = "inner join {biblio_keyword} as bk$bkd on n.vid = bk$bkd.vid";
-          //$joins[] = "inner join {biblio_keyword_data} as bkd on bk.kid= bkd.kid";
+            $joins[] = "INNER JOIN {biblio_keyword} as bk$bkd on n.vid = bk$bkd.vid";
             $where[] = "bk$bkd.kid = %d ";
           }
           elseif (strlen($term[0]) == 1) {
@@ -319,9 +324,9 @@ function biblio_build_query($arg_list) {
             //array_push($args, $type, $term[0]);
           }
           else{
-            $where[] = " bkd". $bkd .'.word '. $match_op .' "[[:<:]]%s[[:>:]]" ';
-            $joins[] = " JOIN {biblio_keyword} as bk". $bkd ." on b.vid = bk". $bkd .".vid ";
-            $joins[] = " JOIN {biblio_keyword_data} as bkd". $bkd ." on bk". $bkd .".kid = bkd".$bkd .".kid ";
+            $where[] = " bkd" . $bkd . '.word ' . $match_op . ' "[[:<:]]%s[[:>:]]" ';
+            $joins[] = " JOIN {biblio_keyword} as bk" . $bkd . " on b.vid = bk" . $bkd . ".vid ";
+            $joins[] = " JOIN {biblio_keyword_data} as bkd" . $bkd . " on bk" . $bkd . ".kid = bkd" . $bkd . ".kid ";
             $terms[] = db_escape_string($term[0]);
             $rss_info['title'] = t("Keyword " . $term[0]);
             $rss_info['description'] = t("These publications, containing the keyword: %keyword, are part of the works listed at %sitename", array('%keyword' => $term[0], '%sitename' => variable_get('site_name', 'Drupal')));
@@ -331,7 +336,7 @@ function biblio_build_query($arg_list) {
           break;
 
         case 'citekey':
-          $term = explode("?",array_shift($arg_list));
+          $term = explode("?", array_shift($arg_list));
           $terms[] = db_escape_string($term[0]);
           $where[] = "b.biblio_citekey= '%s' ";
           array_push($args, $type, $term[0]);
@@ -340,13 +345,12 @@ function biblio_build_query($arg_list) {
         case 'type':
           $term = db_escape_string(array_shift($arg_list));
           $where[] = "b.biblio_type=%d ";
-          //$limit .= $operator. "b.biblio_type=%d ";
-          $terms[] = (int)$term;
-          array_push($args, $type, (int)$term);
+          $terms[] = (int) $term;
+          array_push($args, $type, (int) $term);
           break;
 
         case 'order':
-          $term = (db_escape_string(strtolower(array_shift($arg_list))) == 'desc')?'desc':'asc';
+          $term = (db_escape_string(strtolower(array_shift($arg_list))) == 'desc') ? 'desc' : 'asc';
           $sort_attrib['order'] = $term;
           break;
 
@@ -373,12 +377,11 @@ function biblio_build_query($arg_list) {
               $selects[] = "bcd.lastname";
               break;
 
-            case 'keyword': // added msh 070808
+            case 'keyword':
               $sortby = "ORDER BY bkd.word %s ";
               $joins['bk'] = '  JOIN {biblio_keyword} as bk on b.vid = bk.vid ';
               $joins['bkd'] = '  LEFT JOIN {biblio_keyword_data} as bkd on bk.kid = bkd.kid ';
               $selects[] = "bkd.word as biblio_keyword";
-              //$count_selects[] = "bkd.word";
               break;
 
             case 'year':
@@ -386,13 +389,13 @@ function biblio_build_query($arg_list) {
               $sortby = "ORDER BY b.biblio_year %s, b.biblio_date %s, $sort_title %s";
               $selects[] = "b.biblio_year, b.biblio_date";
               $selects[] = $sort_title;
-          } //end switch
+          }
           break;
 
         case 'search':
           $term = explode("?",array_shift($arg_list));
           $result_nids = split(',', $term[0]);
-          $where[] = "n.nid in (".db_placeholders($result_nids).")";
+          $where[] = "n.nid in (" . db_placeholders($result_nids) . ")";
           foreach ($result_nids as $result_nid) {
             $terms[] = db_escape_string($result_nid);
             array_push($args, $type, $result_nid);
@@ -404,9 +407,9 @@ function biblio_build_query($arg_list) {
 
         default:
           $fields = biblio_get_db_fields();
-          $term = explode("?",array_shift($arg_list));
-          if (in_array("biblio_$type",$fields)) {
-            $where[] = "b.biblio_$type ".$match_op ." '%s' ";
+          $term = explode("?", array_shift($arg_list));
+          if (in_array("biblio_$type", $fields)) {
+            $where[] = "b.biblio_$type " . $match_op . " '%s' ";
             $terms[] = db_escape_string($term[0]);
             array_push($args, $type, $term[0]);
           }
@@ -415,32 +418,40 @@ function biblio_build_query($arg_list) {
     }
   }
   $where[] = "n.type='biblio' ";
-  if ($user->uid != 1 ) {
+  // Show only published content to everyone except super admin user.
+  if ($user->uid != 1) {
     $where[] = 'n.status = 1 ';
-  }//show only published entries to everyone except admin
+  }
 
   $select = implode(', ', $selects);
   $count_select = implode(', ', $count_selects);
   $join = implode(' ', $joins);
 
-  $where_clause = count($where) > 1 ? '('. implode(') AND (', $where) .')': $where[0];
+  $where_clause = count($where) > 1 ? '(' . implode(') AND (', $where) . ')' : $where[0];
 
-  $query = db_rewrite_sql("SELECT $select FROM {node} n $join  WHERE $where_clause $limit $sortby $count_limit");
-  $count_query = db_rewrite_sql("SELECT COUNT($count_select) FROM {node} n $join  WHERE $where_clause $limit $count_limit");
+  $query = db_rewrite_sql("SELECT $select FROM {node} n $join WHERE $where_clause $limit $sortby $count_limit");
+  $count_query = db_rewrite_sql("SELECT COUNT($count_select) FROM {node} n $join WHERE $where_clause $limit $count_limit");
   $_SESSION['last_biblio_query'] = $query;
-  $terms[] = $sort_attrib['order']; // this is either asc or desc to be inserted into the first term of the ORDER clause
-  if($sort_attrib['sort'] == 'year') {
-    $terms[] = $sort_attrib['order']; // we need any extra order term when sorting by year since there are to date terms biblio_year and biblio_date
+  // This is either asc or desc to be inserted into the first term of the ORDER
+  // clause.
+  if (isset($sort_attrib['order'])) {
+    $terms[] = $sort_attrib['order'];
+  }
+  // We need an extra order term when sorting by year since there are two date
+  // terms: biblio_year and biblio_date.
+  if(isset($sort_attrib['sort']) && $sort_attrib['sort'] == 'year') {
+    $terms[] = $sort_attrib['order'];
     $terms[] = 'asc';
   }
   $_SESSION['last_biblio_query_terms'] = $terms;
 
-  return (array('query'      => $query,
-               'query_terms' => $terms,
-               'count_query' => $count_query,
-               'args'        => $args,
-               'sort_attrib' => $sort_attrib,
-               'rss'         => $rss_info
+  return (array(
+    'query'       => $query,
+    'query_terms' => $terms,
+    'count_query' => $count_query,
+    'args'        => $args,
+    'sort_attrib' => $sort_attrib,
+    'rss'         => $rss_info
   ));
 }
 
@@ -478,19 +489,19 @@ function biblio_show_results($nodes, $query_info, $inline = FALSE) {
      popups_add_popups();
   }
   if (!$inline && !$profile) {
-
     if (variable_get('biblio_rss', 0)) {
       drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="' . variable_get('site_name', 'Drupal') . ' RSS" href="' . url("$base/rss.xml") . '" />');
     }
     // Search box. Has same permissions as the filter tab.
     $content = '<div id="biblio-header" class="clear-block">';
-    if (variable_get('biblio_search',0) && user_access('show filter tab')) {
+    if (variable_get('biblio_search', 0) && user_access('show filter tab')) {
       $content .= drupal_get_form('biblio_search_form');
     }
-    if ( biblio_access('export')) {
-      $content .= '<div class="biblio-export">'. theme('biblio_export_links'). '</div>';
-    }else{
-      $content .= '<div class="biblio-export">'.t('Found @count results', array('@count' => $pager_total_items[0])) .'</div><br />';
+    if (biblio_access('export')) {
+      $content .= '<div class="biblio-export">' . theme('biblio_export_links') . '</div>';
+    }
+    else {
+      $content .= '<div class="biblio-export">' . t('Found @count results', array('@count' => $pager_total_items[0])) . '</div><br />';
     }
     // Add some links to the top of the page to change the sorting/ordering...
     if (user_access('show sort links')) {
@@ -499,11 +510,11 @@ function biblio_show_results($nodes, $query_info, $inline = FALSE) {
     $content .= '</div>';
 
     if  (user_access('show filter tab')) {
-      $content .=  $query_info['filter_line'];
+      $content .= $query_info['filter_line'];
     }
   }
 
-  if ($inline === true) print '<div class="biblio-inline">';
+  if ($inline === TRUE) print '<div class="biblio-inline">';
 
   if (isset($_GET['sort'])) {
     $value = '';
@@ -513,7 +524,7 @@ function biblio_show_results($nodes, $query_info, $inline = FALSE) {
       if (strpos($_GET['q'],'ag') ||
           strpos($_GET['q'],'tg') ||
           strpos($_GET['q'],'keyword')) {
-        $value = substr($_GET['q'],strrpos($_GET['q'],'/') + 1);
+        $value = substr($_GET['q'], strrpos($_GET['q'], '/') + 1);
       }
       $content .= theme('biblio_alpha_line', $_GET['sort'], $value);
     }
@@ -525,10 +536,15 @@ function biblio_show_results($nodes, $query_info, $inline = FALSE) {
 
   foreach ($nodes as $node) {
     $count++;
-    if (is_array($node)) $node = (object)$node;
-    if (variable_get('biblio_hide_bibtex_braces', 0)) $node->title = biblio_remove_brace($node->title);
-    if (variable_get('biblio_fix_isi_links', 0)) biblio_fix_isi_links($node);
-
+    if (is_array($node)) {
+      $node = (object) $node;
+    }
+    if (variable_get('biblio_hide_bibtex_braces', 0)) {
+      $node->title = biblio_remove_brace($node->title);
+    }
+    if (variable_get('biblio_fix_isi_links', 0)) {
+      biblio_fix_isi_links($node);
+    }
 
     // Add a separator bar if needed.
     $content .= _biblio_category_separator_bar($attrib, $node);
@@ -576,9 +592,12 @@ function _biblio_sort_tabs($attrib, $options = NULL) {
   $content = '';
   $sort_links = array();
   $tabs = variable_get('biblio_sort_tabs_style', 0);
-  // What is the default for $order in event $attrib['order'] not defined?
-  $order = ($attrib['order'] == "desc" || $attrib['order'] == "DESC") ? "asc" : "desc";
-  $cur_order = ($attrib['order'] == "desc" || $attrib['order'] == "DESC") ? "desc" : "asc";
+  $order = 'desc';
+  $cur_order = 'asc';
+  if (isset($attrib['order']) && (strtolower($attrib['order'] == "desc"))) {
+    $order = 'asc';
+    $cur_oreder = 'desc';
+  }
   $path = drupal_get_path('module', 'biblio');
   $order_arrow = ($order == 'asc')
                    ? ' <img src ="' . $base_path . $path . '/misc/arrow-asc.png" alt =" (Desc)" />'
@@ -598,7 +617,7 @@ function _biblio_sort_tabs($attrib, $options = NULL) {
     $tab['attributes'] = array("title"=>t("Click a second time to reverse the sort order"));
     $tab['html'] = TRUE;
     $tab['text'] = t(ucfirst($title));
-    if ($key === $title && $title == $attrib['sort']) {
+    if ($key === $title && isset($attrib['sort']) && $title == $attrib['sort']) {
       $tab['query'] = array('sort' => $title, 'order' => $order);
       $tab['attributes'] +=  array('class' => "active");
       $tab['active'] = TRUE;
@@ -715,7 +734,7 @@ function _biblio_filter_info_line($args) {
         }
       }
       array_shift($args);
-      $params = array('%a' =>  check_plain(ucwords($type)) , '%b' =>  check_plain($value) );
+      $params = array('%a' => check_plain(ucwords($type)) , '%b' => check_plain($value) );
       $filtercontent .= ($i++ ? t('<em> and</em> <strong>%a</strong> is <strong>%b</strong>', $params) : t('<strong>%a</strong> is <strong>%b</strong>', $params)) ;
     }
     if ($search_content) {
@@ -733,17 +752,17 @@ function _biblio_filter_info_line($args) {
     $link_options = array();
     $link_options['query'] = '';
     if (isset($_GET['sort'])) {
-      $link_options['query']  .= "sort=" . $_GET['sort'];
+      $link_options['query'] .= "sort=" . $_GET['sort'];
     }
     if (isset($_GET['order'])) {
-      $link_options['query']   .= $link_options['query'] ? "&" : "" ;
-      $link_options['query']   .= "order=" . $_GET['order'];
+      $link_options['query'] .= $link_options['query'] ? "&" : "" ;
+      $link_options['query'] .= "order=" . $_GET['order'];
     }
 
     if ($search_content) {
-      $content .= '&nbsp;&nbsp;'.l('['.t('Reset Search').']',"$base/filter/clear", $link_options);
+      $content .= '&nbsp;&nbsp;' . l('[' . t('Reset Search') . ']', "$base/filter/clear", $link_options);
     } else {
-      $content .= '&nbsp;&nbsp;'.l('['.t('Clear All Filters').']',"$base/filter/clear", $link_options);
+      $content .= '&nbsp;&nbsp;' . l('[' . t('Clear All Filters') . ']',"$base/filter/clear", $link_options);
     }
     $content .= '</div>';
   }
@@ -785,7 +804,7 @@ function _biblio_category_separator_bar($attrib, $node, $reset = FALSE) {
     case 'author':
       if ( (isset($node->biblio_contributors[1][0]['lastname'])) &&
         (drupal_substr(drupal_ucfirst(ltrim($node->biblio_contributors[1][0]['lastname'])), 0, 1) != $_text)) {
-        if ($_text != '' ) {
+        if ($_text != '') {
           $content .= theme_biblio_end_category_section();
         }
         $_text = drupal_substr(drupal_ucfirst(ltrim($node->biblio_contributors[1][0]['lastname'])), 0, 1);
@@ -795,7 +814,7 @@ function _biblio_category_separator_bar($attrib, $node, $reset = FALSE) {
 
     case 'type':
       if ($node->biblio_type_name != $_text) {
-        if ($_text != '' ) {
+        if ($_text != '') {
           $content .= theme_biblio_end_category_section();
         }
         $_text = $node->biblio_type_name;
@@ -843,8 +862,8 @@ function _biblio_category_separator_bar($attrib, $node, $reset = FALSE) {
  *
  */
 function theme_biblio_separator_bar($text) {
-  $content = "\n".'<div class="biblio-separator-bar">' . check_plain($text) . "</div>\n";
-  $content .= "\n".'<div class ="biblio-category-section">';
+  $content  = "\n" . '<div class="biblio-separator-bar">' . check_plain($text) . "</div>\n";
+  $content .= "\n" . '<div class="biblio-category-section">';
   return $content;
 }
 
@@ -1073,10 +1092,11 @@ function _get_biblio_filters() {
  * @return array $form
  *   An assoicative array with form elements for the biblio content filter.
  *
- * @see biblio_form_filter_submit()
+ * @see biblio_filter_form_submit()
+ *
  * @ingroup forms
  */
-function biblio_form_filter() {
+function biblio_filter_form() {
   // No longer use &$_SESSION so that we can alter $session in case of the search filter.
   $session = $_SESSION['biblio_filter'];
   $session = is_array($session) ? $session : array();
@@ -1090,7 +1110,8 @@ function biblio_form_filter() {
   );
   foreach ($session as $filter) {
     list($type, $value) = $filter;
-    // Don't show the search filter. Reset $session because of the $count(session) below.
+    // Don't show the search filter. Reset $session because of the
+    // $count(session) below.
     if ($type == 'search') {
       $session = array();
       break;
@@ -1127,9 +1148,9 @@ function biblio_form_filter() {
 }
 
 /**
- * Form submission handler for biblio_form_filter().
+ * Form submission handler for biblio_filter_form().
  */
-function biblio_form_filter_submit($form, &$form_state) {
+function biblio_filter_form_submit($form, &$form_state) {
   // If the search filter was set, remove it now.
   if(_get_biblio_search_filter()){
     $_SESSION['biblio_filter'] = array ();
@@ -1469,7 +1490,7 @@ function _biblio_get_keywords($filter = NULL) {
   $keywords = array();
   $where = array();
   $where_clause = '';
-  
+
   if ($filter) {
     $filter = strtoupper($filter);
     $where[] =  "UPPER(SUBSTRING(word,1,1)) = '%s' ";
diff --git a/includes/biblio_theme.inc b/includes/biblio_theme.inc
index 88d22d2..158398a 100644
--- a/includes/biblio_theme.inc
+++ b/includes/biblio_theme.inc
@@ -1,28 +1,32 @@
 <?php
 /**
  * @file
- *
+ * Theme functions for the Drupal biblio module.
  */
 
 module_load_include('inc', 'biblio', 'includes/biblio.pages');
 
 /**
- *
+ * Creates HTML for a biblio coin button.
  *
  * @param array $element
- *
+ *   An array containing keys that define this button.
  *
  * @ingroup themeable
  */
 function theme_biblio_coin_button($element) {
-  return '<a href="/biblio/regen_coins"><input type="button"  name="' . $element['#name'] . '" value="' . $element['#value'] . '"  /></a>';
+  // @todo: Add CSS class or ID for targetting format via CSS.
+  $name = isset($element['#name']) ? $element['#name'] : '';
+  $value = isset($element['#value']) ? $element['#value'] : '';
+  $output = '<a href="/biblio/regen_coins"><input type="button"  name="' . $name . '" value="' . $value . '" /></a>';
+  return $output;
 }
 
 /**
  *
  *
  * @param object $node
- *
+ *   A node object possibly with biblio_baseopenurl property.
  *
  * @ingroup themeable
  */
@@ -93,8 +97,8 @@ function biblio_openURL($node) {
     $query[$coKey] = rawurlencode($coValue);
   }
 
-  $sid = "biblio:". variable_get('site_name', 'Drupal');
-  $user_sid = !empty($user->biblio_openurl_sid)?$user->biblio_openurl_sid:'';
+  $sid = "biblio:" . variable_get('site_name', 'Drupal');
+  $user_sid = !empty($user->biblio_openurl_sid) ? $user->biblio_openurl_sid : '';
   $query["sid"] = !empty($user_sid) ? check_plain($user_sid) : check_plain(variable_get('biblio_openurl_sid', $sid));
 
   return $query;
@@ -257,7 +261,7 @@ function theme_biblio_tabular($node, $base = 'biblio', $teaser = false) {
     $attrib = (variable_get('biblio_links_target_new_window', null)) ? array('target' => '_blank') : array();
     if ( ($doi_start = strpos($node->biblio_doi, '10.')) !== FALSE) {
       $doi = substr($node->biblio_doi, $doi_start);
-      $doi_url .= 'http://dx.doi.org/'. $doi;
+      $doi_url .= 'http://dx.doi.org/' . $doi;
     }
     $node->biblio_doi = l($node->biblio_doi, $doi_url, $attrib);
   }
@@ -267,7 +271,7 @@ function theme_biblio_tabular($node, $base = 'biblio', $teaser = false) {
     if ($row['type'] == 'contrib_widget' && !empty($node->biblio_contributors[$row['fid']][0]['name']) ) {
       $data = biblio_format_authors($node->biblio_contributors[$row['fid']]);
     }
-    elseif (empty ($node->$row['name']) || $row['name'] == 'biblio_coins') {
+    elseif (empty($node->$row['name']) || $row['name'] == 'biblio_coins') {
       continue;
     }
     else {
@@ -275,12 +279,14 @@ function theme_biblio_tabular($node, $base = 'biblio', $teaser = false) {
         case 'biblio_keywords' :
           $data = _biblio_keyword_links($node->$row['name'], $base);
           break;
+          
         case 'biblio_url' :
         case 'biblio_doi' :
           // check_plain is not need on these since they have gone through
           // the l() function which does a check_plain
           $data = $node-> $row['name'];
           break;
+        
         default :
           if ($row['type'] == 'textarea') {
             $format = isset($node->biblio_formats[$row['name']]) ? $node->biblio_formats[$row['name']] : $node->format;
@@ -289,27 +295,26 @@ function theme_biblio_tabular($node, $base = 'biblio', $teaser = false) {
           else {
             $data = check_plain($node-> $row['name']);
           }
+          break;
       }
     }
     $rows[] = array(
-    array(
+      array(
         'data' => t($row['title']),
-        'class' => 'biblio-row-title biblio-field-title-'.str_replace('_', '-', str_replace('biblio_', '', $row['name']))
-    ),
-    array(
+        'class' => 'biblio-row-title biblio-field-title-' . str_replace('_', '-', str_replace('biblio_', '', $row['name'])),
+      ),
+      array(
         'data' => $data,
-        'class' => 'biblio-field-contents-'.str_replace('_', '-', str_replace('biblio_', '', $row['name']))
-    )
+        'class' => 'biblio-field-contents-' . str_replace('_', '-', str_replace('biblio_', '', $row['name'])),
+      ),
     );
   }
 
-
   if (strlen(trim($node->body)) && user_access('view full text')) {
     $rows[] = array(
-    array('data' => t('Full Text'),  'valign' => 'top'),
-    array('data' =>  check_markup($node->body, $node->format, FALSE))
+      array('data' => t('Full Text'), 'valign' => 'top'),
+      array('data' =>  check_markup($node->body, $node->format, FALSE))
     );
-
   }
   $output = '<div id="biblio-node">';
   $output .= filter_xss($node->biblio_coins, array('span'));
@@ -336,7 +341,7 @@ function theme_biblio_tabular($node, $base = 'biblio', $teaser = false) {
  * @ingroup themeable
  */
 function theme_biblio_authors($contributors, $style = 'classic', $cat = 1, $inline = false, $glue = ', ') {
-  // Immediately return if there are no contributors
+  // Immediately return if there are no contributors.
   if (empty($contributors)) {
     // @todo: Shouldn't this return any empty string?
     return;
@@ -867,18 +872,18 @@ function theme_biblio_style($node, $base = 'biblio', $style_name = 'classic', $i
  * @ingroup themeable
  */
 function theme_biblio_entry($node, $base = 'biblio', $style = 'classic', $inline = false) {
-  $output  = "\n".'<div class="biblio-entry">' . "\n" ;
-  $output  .= '<div class="biblio-style-'. $style . '">' . "\n" ;
+  $output  = "\n" . '<div class="biblio-entry">' . "\n" ;
+  $output .= '<div class="biblio-style-'. $style . '">' . "\n" ;
   if (!$node->status) {
     $output .= '<div id="node-'.$node->nid.'" class="node node-unpublished">';
   }
-  // first add the styled entry...
+  // First add the styled entry...
   $output .= theme('biblio_style', $node, $base, $style, $inline);
 
-  // now add the various links
+  // Now add the various links.
   if ($node->biblio_abst_e) {
     $output .= '<span class="biblio-abstract-link">';
-    $output .= l(" Abstract", "node/$node->nid") ."\n";
+    $output .= l(" Abstract", "node/$node->nid") . "\n";
     $output .= '</span>';
   }
   $annotation_field = variable_get('biblio_annotations', 'none');
@@ -894,46 +899,47 @@ function theme_biblio_entry($node, $base = 'biblio', $style = 'classic', $inline
   }
 
   if (biblio_access('export', $node)) {
-    $output .= theme('biblio_export_links',$node);
+    $output .= theme('biblio_export_links', $node);
   }
 
   if (biblio_access('download', $node)) {
     // add links to attached files (if any)
-    $output .= theme('biblio_download_links',$node);
+    $output .= theme('biblio_download_links', $node);
   }
   if (!$node->status) {
     $output .= '</div>';
   }
 
   $output .= "\n</div></div>";
-
   return $output;
 }
 
 /**
+ * Returns HTML string for the filter in biblio_filter_form.
  *
+ * @param array $form
+ *   A form array with keys that defines the filter form and its elements.
  *
- * @param $form
- *
- * @see biblio_filters()
+ * @see biblio_filter_form()
  *
  * @ingroup themeable
  */
 function theme_biblio_filters($form) {
   $output = '';
-  if (sizeof($form['current'])) {
+  $size = isset($form['current']) ? count($form['current']) : 0;
+  if ($size > 0) {
     $output .= '<ul>';
     foreach (element_children($form['current']) as $key) {
       $output .= '<li>' . drupal_render($form['current'][$key]) . '</li>';
     }
     $output .= '</ul>';
   }
-  $output .= '<dl class="multiselect">' . (sizeof($form['current']) ? '<dt><em>' . t('and') . '</em> ' . t('where') . '</dt>' : '') . '<dd class="a">';
+  $output .= '<dl class="multiselect">' . (($size > 0) ? '<dt><em>' . t('and') . '</em> ' . t('where') . '</dt>' : '') . '<dd class="a">';
   foreach (element_children($form['filter']) as $key) {
     $output .= drupal_render($form['filter'][$key]);
   }
   $output .= '</dd>';
-  $output .= '<dt>'. t('is') .'</dt><dd class="b">';
+  $output .= '<dt>' . t('is') . '</dt><dd class="b">';
   foreach (element_children($form['status']) as $key) {
     $output .= drupal_render($form['status'][$key]);
   }
@@ -945,9 +951,12 @@ function theme_biblio_filters($form) {
 }
 
 /**
+ * Returns HTML string for complete biblio_filter_form.
+
  * @param $form
+ *   A form array with keys that defines the filter form and its elements.
  *
- * @see biblio_admin_types_edit_form()
+ * @see biblio_filter_form()
  *
  * @ingroup themeable
  */
