Index: /trunk/bin/module_maker/skel/admin.php
===================================================================
--- /trunk/bin/module_maker/skel/admin.php	(revision 152)
+++ /trunk/bin/module_maker/skel/admin.php	(revision 153)
@@ -34,9 +34,9 @@
 
 // Configure the prefs object.
-$prefs =& Prefs::getInstance('%NAME_PLURAL%');
-$prefs->setParam(array('persistent' => false));
+$tmp_prefs = new Prefs('%NAME_PLURAL%');
+$tmp_prefs->setParam(array('persistent' => false));
 
 // Configure the cache object.
-$cache =& Cache::getInstance('%NAME_PLURAL%');
+$cache = new Cache('%NAME_PLURAL%');
 $cache->setParam(array('enable' => true));
 
@@ -255,6 +255,6 @@
 {
     global $lock;
+    global $cache;
 	$db =& DB::getInstance();
-	$cache =& Cache::getInstance('%NAME_PLURAL%');
 	
     $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $id);
@@ -290,6 +290,6 @@
 {
     global $auth;
+    global $cache;
 	$db =& DB::getInstance();
-	$cache =& Cache::getInstance('%NAME_PLURAL%');
 	
     // Remove any stale cached list data.
@@ -311,6 +311,6 @@
 {
 	global $auth, $lock;
+    global $cache;
 	$app =& App::getInstance();
-    $cache =& Cache::getInstance('%NAME_PLURAL%');
     
     $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $frm['%PRIMARY_KEY%']);
@@ -338,7 +338,7 @@
     global $page;
     global $so;
+    global $tmp_prefs;
+    global $cache;
 	$db =& DB::getInstance();	
-	$prefs =& Prefs::getInstance('%NAME_PLURAL%');
-	$cache =& Cache::getInstance('%NAME_PLURAL%');
     
     $where_clause = '';
@@ -390,7 +390,7 @@
     // without knowing the hash.
     $cache_hash = md5($sql . '|' . $page->total_items);
-    if ($prefs->get('cache_hash') != $cache_hash) {
+    if ($tmp_prefs->get('cache_hash') != $cache_hash) {
         $cache->delete('list');
-        $prefs->set('cache_hash', $cache_hash);
+        $tmp_prefs->set('cache_hash', $cache_hash);
     }
 
@@ -416,6 +416,6 @@
 function updateRank($ranks)
 {
+    global $cache;
 	$db =& DB::getInstance();
-	$cache =& Cache::getInstance('%NAME_PLURAL%');
 	
     if (!is_array($ranks)) {
Index: /trunk/lib/Cache.inc.php
===================================================================
--- /trunk/lib/Cache.inc.php	(revision 152)
+++ /trunk/lib/Cache.inc.php	(revision 153)
@@ -131,5 +131,5 @@
         }
 
-        $key = md5($key);
+        $keyhash = md5($key);
         $var = serialize($var);
         $var_len = strlen($var);
@@ -146,5 +146,5 @@
 
         // Remove any value already stored under this key.
-        unset($_SESSION[$this->_ns][$key]);
+        unset($_SESSION[$this->_ns][$keyhash]);
 
         // Continue to prune the cache if its size is greater than stack_size_limit, but keep at least min_items.
@@ -154,5 +154,5 @@
 
         // Save this value under the specified key.
-        $_SESSION[$this->_ns][$key] =& $var;
+        $_SESSION[$this->_ns][$keyhash] =& $var;
 
         if ($var_len >= 1024000) {
@@ -174,16 +174,20 @@
     function get($key)
     {
+        $app =& App::getInstance();
+        
         if (true !== $this->getParam('enabled')) {
-            return false;
-        }
-
-        $key = md5($key);
-        if (isset($_SESSION[$this->_ns][$key])) {
+            $app->logMsg(sprintf('Cache not enabled, not getting data.', null), LOG_DEBUG, __FILE__, __LINE__);
+            return false;
+        }
+
+        $keyhash = md5($key);
+        if (isset($_SESSION[$this->_ns][$keyhash])) {
+            $app->logMsg(sprintf('Retreiving %s from cache.', $key), LOG_DEBUG, __FILE__, __LINE__);
             // Move the accessed cached datum to the top of the stack. Maybe somebody knows a better way to do this?
-            $tmp =& $_SESSION[$this->_ns][$key];
-            unset($_SESSION[$this->_ns][$key]);
-            $_SESSION[$this->_ns][$key] =& $tmp;
+            $tmp =& $_SESSION[$this->_ns][$keyhash];
+            unset($_SESSION[$this->_ns][$keyhash]);
+            $_SESSION[$this->_ns][$keyhash] =& $tmp;
             // Return the unserialized datum.
-            return unserialize($_SESSION[$this->_ns][$key]);
+            return unserialize($_SESSION[$this->_ns][$keyhash]);
         } else {
             return false;
@@ -203,6 +207,6 @@
         }
 
-        $key = md5($key);
-        return array_key_exists($key, $_SESSION[$this->_ns]);
+        $keyhash = md5($key);
+        return array_key_exists($keyhash, $_SESSION[$this->_ns]);
     }
 
@@ -215,6 +219,6 @@
     function delete($key)
     {
-        $key = md5($key);
-        unset($_SESSION[$this->_ns][$key]);
+        $keyhash = md5($key);
+        unset($_SESSION[$this->_ns][$keyhash]);
     }
     
Index: /trunk/lib/PageNumbers.inc.php
===================================================================
--- /trunk/lib/PageNumbers.inc.php	(revision 152)
+++ /trunk/lib/PageNumbers.inc.php	(revision 153)
@@ -65,4 +65,7 @@
         // in special cases like using a /my/page/# scheme.
         $this->url_base = $_SERVER['PHP_SELF'] . '?page_number=';
+        
+        $this->prefs = new Prefs();
+        $this->prefs->setParam(array('persistent' => false));
     }
 
@@ -72,7 +75,4 @@
     function setPerPage($per_page, $default=25, $save_value=true)
     {
-		$prefs =& Prefs::getInstance($_SERVER['PHP_SELF']);
-		$prefs->setParam(array('persistent' => false));
-    
     	// (1) By provided argument, if valid.
         // (2) By saved preference, if available.
@@ -82,8 +82,8 @@
             $this->_per_page = $per_page;
             if ($save_value) {
-                $prefs->set('items_per_page', $this->_per_page);
-            }
-        } else if ($save_value && $prefs->exists('items_per_page')) {
-            $this->_per_page = (int)$prefs->get('items_per_page');
+                $this->prefs->set('items_per_page', $this->_per_page);
+            }
+        } else if ($save_value && $this->prefs->exists('items_per_page')) {
+            $this->_per_page = (int)$this->prefs->get('items_per_page');
         } else if (is_numeric($default) && $default > 0) {
             $this->_per_page = $default;
@@ -97,7 +97,4 @@
     function setPageNumber($page_number, $save_value=true)
     {
-		$prefs =& Prefs::getInstance($_SERVER['PHP_SELF']);
-		$prefs->setParam(array('persistent' => false));
-    
         // (1) By provided argument, if valid.
         // (2) By saved preference, if available.
@@ -111,8 +108,8 @@
             }
             if ($save_value) {
-                $prefs->set('page_number', $this->current_page);
-            }
-        } else if ($save_value && $prefs->exists('page_number')) {
-            $this->current_page = (int)$prefs->get('page_number');
+                $this->prefs->set('page_number', $this->current_page);
+            }
+        } else if ($save_value && $this->prefs->exists('page_number')) {
+            $this->current_page = (int)$this->prefs->get('page_number');
         }
         $this->set_page_number_initialized = true;
Index: /trunk/lib/Prefs.inc.php
===================================================================
--- /trunk/lib/Prefs.inc.php	(revision 152)
+++ /trunk/lib/Prefs.inc.php	(revision 153)
@@ -14,5 +14,5 @@
 // Load preferences for the user's session.
 require_once 'codebase/lib/Prefs.inc.php';
-$prefs =& Prefs::getInstance('my-namespace');
+$prefs = new Prefs('my-namespace');
 $prefs->setParam(array(
     'persistent' => $auth->isLoggedIn(),
@@ -74,22 +74,4 @@
             $this->setParam(array('create_table' => $app->getParam('db_create_tables')));
         }
-    }
-
-    /**
-     * This method enforces the singleton pattern for this class.
-     *
-     * @return  object  Reference to the global Prefs object.
-     * @access  public
-     * @static
-     */
-    function &getInstance($namespace='')
-    {
-        static $instances = array();
-
-        if (!array_key_exists($namespace, $instances)) {
-            $instances[$namespace] = new Prefs($namespace);
-        }
-
-        return $instances[$namespace];
     }
 
Index: /trunk/lib/SortOrder.inc.php
===================================================================
--- /trunk/lib/SortOrder.inc.php	(revision 152)
+++ /trunk/lib/SortOrder.inc.php	(revision 153)
@@ -39,4 +39,7 @@
         $this->default_sort = $default_sort;
         $this->default_order = $default_order;
+        
+        $this->prefs = new Prefs();
+        $this->prefs->setParam(array('persistent' => false));
     }
 
@@ -69,7 +72,4 @@
     function setDefault($default_sort = '', $default_order = '')
     {
-		$prefs =& Prefs::getInstance($_SERVER['PHP_SELF']);
-		$prefs->setParam(array('persistent' => false));
-
         // Which column to sort by?
         // (1) By GET or POST specification, if available.
@@ -79,7 +79,7 @@
         if (!empty($new_sort_by)) {
             $this->sort_by = $new_sort_by;
-            $prefs->set('sort_by', $this->sort_by);
-        } else if ($prefs->exists('sort_by')) {
-            $this->sort_by = $prefs->get('sort_by');
+            $this->prefs->set('sort_by', $this->sort_by);
+        } else if ($this->prefs->exists('sort_by')) {
+            $this->sort_by = $this->prefs->get('sort_by');
         } else {
             $this->sort_by = $default_sort;
@@ -93,7 +93,7 @@
         if (!empty($new_order)) {
             $this->order = $new_order;
-            $prefs->set('sort_order', $this->order);
-        } else if ($prefs->exists('sort_order')) {
-            $this->order = $prefs->get('sort_order');
+            $this->prefs->set('sort_order', $this->order);
+        } else if ($this->prefs->exists('sort_order')) {
+            $this->order = $this->prefs->get('sort_order');
         } else {
             $this->order = $default_order;
@@ -112,11 +112,8 @@
     function set($sort = null, $order = null)
     {
-		$prefs =& Prefs::getInstance($_SERVER['PHP_SELF']);
-		$prefs->setParam(array('persistent' => false));
-
         // Set new sort value.
         if (isset($sort)) {
             $this->sort_by = $sort;
-            $prefs->set('sort_by', $this->sort_by);
+            $this->prefs->set('sort_by', $this->sort_by);
         }
 
@@ -124,5 +121,5 @@
         if (isset($order)) {
             $this->order = $order;
-            $prefs->set('sort_order', $this->order);
+            $this->prefs->set('sort_order', $this->order);
         }
     }
Index: /trunk/services/admins.php
===================================================================
--- /trunk/services/admins.php	(revision 152)
+++ /trunk/services/admins.php	(revision 153)
@@ -31,9 +31,9 @@
 
 // Configure the prefs object.
-$prefs =& Prefs::getInstance('admins');
-$prefs->setParam(array('persistent' => false));
+$tmp_prefs = new Prefs('admins');
+$tmp_prefs->setParam(array('persistent' => false));
 
 // Configure the cache object.
-$cache =& Cache::getInstance('admins');
+$cache = new Cache('admins');
 $cache->setParam(array('enable' => true));
 
@@ -322,8 +322,9 @@
 function deleteRecord($id)
 {
-    global $auth, $lock;
+    global $auth;
+    global $lock;
+    global $cache;
 	$app =& App::getInstance();
 	$db =& DB::getInstance();
-	$cache =& Cache::getInstance('admins');
 	
     $lock->select('admin_tbl', 'admin_id', $id);
@@ -371,7 +372,7 @@
 {
     global $auth;
+    global $cache;
 	$app =& App::getInstance();
 	$db =& DB::getInstance();
-	$cache =& Cache::getInstance('admins');
 	
     // Remove any stale cached list data.
@@ -414,8 +415,9 @@
 function updateRecord($frm)
 {
-    global $auth, $lock;
+    global $auth;
+    global $lock;
+    global $cache;
 	$app =& App::getInstance();
 	$db =& DB::getInstance();
-	$cache =& Cache::getInstance('admins');
 	
     $lock->select('admin_tbl', 'admin_id', $frm['admin_id']);
@@ -460,7 +462,7 @@
     global $page;
     global $so;
+    global $tmp_prefs;
+    global $cache;
 	$db =& DB::getInstance();
-	$prefs =& Prefs::getInstance('admins');
-	$cache =& Cache::getInstance('admins');
 	
     $where_clause = '';
@@ -514,7 +516,7 @@
     // without knowing the hash.
     $cache_hash = md5($sql . '|' . $page->total_items);
-    if ($prefs->get('cache_hash') != $cache_hash) {
+    if ($tmp_prefs->get('cache_hash') != $cache_hash) {
         $cache->delete('list');
-        $prefs->set('cache_hash', $cache_hash);
+        $tmp_prefs->set('cache_hash', $cache_hash);
     }
 
Index: /trunk/services/logs.php
===================================================================
--- /trunk/services/logs.php	(revision 152)
+++ /trunk/services/logs.php	(revision 153)
@@ -37,14 +37,14 @@
 $no_download_files = '/^$/';
 
-
-// Set the defaults and catch incoming settings.
-$prefs =& Prefs::getInstance('admin_logs');
-$prefs->setDefaults(array(
+// Configure the prefs object.
+$tmp_prefs = new Prefs('admin_logs');
+$tmp_prefs->setParam(array('persistent' => false));
+$tmp_prefs->setDefaults(array(
     'log_file' => $app->getParam('log_filename')
 ));
-$prefs->set('log_file', getFormData('log'));
+$tmp_prefs->set('log_file', getFormData('log'));
 
 // Titles and navigation header.
-$nav->addPage(sprintf(_("Viewing log: <em>%s</em>"), $prefs->get('log_file')), '/admin/logs.php');
+$nav->addPage(sprintf(_("Viewing log: <em>%s</em>"), $tmp_prefs->get('log_file')), '/admin/logs.php');
 
 /********************************************************************
@@ -59,6 +59,6 @@
 case 'delete' :
 //     $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET);
-    deleteLog($prefs->get('log_file'));
-    $prefs->set('log_file', $app->getParam('log_filename'));
+    deleteLog($tmp_prefs->get('log_file'));
+    $tmp_prefs->set('log_file', $app->getParam('log_filename'));
     if ($app->validBoomerangURL('app_log')) {
         // Display boomerang page.
@@ -71,5 +71,5 @@
 case 'clear' :
 //     $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET);
-    clearLog($prefs->get('log_file'));
+    clearLog($tmp_prefs->get('log_file'));
     if ($app->validBoomerangURL('app_log')) {
         // Display boomerang page.
@@ -82,5 +82,5 @@
 case 'archive' :
 //     $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET);
-    if (archiveLog($prefs->get('log_file'))) {
+    if (archiveLog($tmp_prefs->get('log_file'))) {
         // Now flush current log.
         $app->dieURL($_SERVER['PHP_SELF'] . '?op=clear');
@@ -100,11 +100,11 @@
 case 'download' :
     header('Content-Type: application/octet-stream');
-    header(sprintf('Content-Disposition: attachment; filename=%s.txt', $prefs->get('log_file')));
-    printLog($prefs->get('log_file'));
+    header(sprintf('Content-Disposition: attachment; filename=%s.txt', $tmp_prefs->get('log_file')));
+    printLog($tmp_prefs->get('log_file'));
     die;
     break;
 
 default :
-    $list =& getLog($prefs->get('log_file'), getFormData('search_query'));
+    $list =& getLog($tmp_prefs->get('log_file'), getFormData('search_query'));
     $main_template = 'log_list.ihtml';
     break;
@@ -128,5 +128,5 @@
 include 'header.ihtml';
 if ('output' == $main_template) {
-    printLog($prefs->get('log_file'));
+    printLog($tmp_prefs->get('log_file'));
 } else {
     include 'codebase/services/templates/' . $main_template;
Index: /trunk/services/templates/log_list.ihtml
===================================================================
--- /trunk/services/templates/log_list.ihtml	(revision 152)
+++ /trunk/services/templates/log_list.ihtml	(revision 153)
@@ -10,5 +10,5 @@
         <tr class="commandtext">
             <td>
-                <?php if ($l['filename'] == $prefs->get('log_file')) { ?>
+                <?php if ($l['filename'] == $tmp_prefs->get('log_file')) { ?>
                     <span class="commanditem"><strong><?php echo sprintf(_("%s"), $l['filename']); ?></strong></span>
                 <?php } else { ?>
