Merge pull request #823 from narfbg/develop-session

Improve the Session library
diff --git a/application/config/database.php b/application/config/database.php
index 58eec4b..880773d 100644
--- a/application/config/database.php
+++ b/application/config/database.php
@@ -41,7 +41,7 @@
 |	['username'] The username used to connect to the database
 |	['password'] The password used to connect to the database
 |	['database'] The name of the database you want to connect to
-|	['dbdriver'] The database type. ie: mysql.  Currently supported:
+|	['dbdriver'] The database type. e.g.: mysql.  Currently supported:
 				 mysql, mysqli, pdo, postgre, odbc, mssql, sqlite, oci8
 |	['dbprefix'] You can add an optional prefix, which will be added
 |				 to the table name when using the  Active Record class
diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
index 97527e5..04f346c 100755
--- a/system/core/CodeIgniter.php
+++ b/system/core/CodeIgniter.php
@@ -59,14 +59,7 @@
  *  Load the framework constants
  * ------------------------------------------------------
  */
-	if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/constants.php'))
-	{
-		require(APPPATH.'config/'.ENVIRONMENT.'/constants.php');
-	}
-	else
-	{
-		require(APPPATH.'config/constants.php');
-	}
+ 	load_environ_config('constants', TRUE);
 
 /*
  * ------------------------------------------------------
diff --git a/system/core/Common.php b/system/core/Common.php
index b0921fe..9e05f3d 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -47,7 +47,6 @@
 * Since there are a few places where we conditionally test for PHP > 5
 * we'll set a static variable.
 *
-* @access	public
 * @param	string
 * @return	bool	TRUE if the current version is $version or higher
 */
@@ -76,7 +75,6 @@
  * the file, based on the read-only attribute.  is_writable() is also unreliable
  * on Unix servers if safe_mode is on.
  *
- * @access	private
  * @return	void
  */
 if ( ! function_exists('is_really_writable'))
@@ -118,18 +116,17 @@
 // ------------------------------------------------------------------------
 
 /**
-* Class registry
-*
-* This function acts as a singleton.  If the requested class does not
-* exist it is instantiated and set to a static variable.  If it has
-* previously been instantiated the variable is returned.
-*
-* @access	public
-* @param	string	the class name being requested
-* @param	string	the directory where the class should be found
-* @param	string	the class name prefix
-* @return	object
-*/
+ * Class registry
+ *
+ * This function acts as a singleton.  If the requested class does not
+ * exist it is instantiated and set to a static variable.  If it has
+ * previously been instantiated the variable is returned.
+ *
+ * @param	string	the class name being requested
+ * @param	string	the directory where the class should be found
+ * @param	string	the class name prefix
+ * @return	object
+ */
 if ( ! function_exists('load_class'))
 {
 	function &load_class($class, $directory = 'libraries', $prefix = 'CI_')
@@ -191,12 +188,11 @@
 // --------------------------------------------------------------------
 
 /**
-* Keeps track of which libraries have been loaded.  This function is
-* called by the load_class() function above
-*
-* @access	public
-* @return	array
-*/
+ * Keeps track of which libraries have been loaded.  This function is
+ * called by the load_class() function above
+ *
+ * @return	array
+ */
 if ( ! function_exists('is_loaded'))
 {
 	function is_loaded($class = '')
@@ -215,14 +211,13 @@
 // ------------------------------------------------------------------------
 
 /**
-* Loads the main config.php file
-*
-* This function lets us grab the config file even if the Config class
-* hasn't been instantiated yet
-*
-* @access	private
-* @return	array
-*/
+ * Loads the main config.php file
+ *
+ * This function lets us grab the config file even if the Config class
+ * hasn't been instantiated yet
+ *
+ * @return	array
+ */
 if ( ! function_exists('get_config'))
 {
 	function &get_config($replace = array())
@@ -273,11 +268,10 @@
 // ------------------------------------------------------------------------
 
 /**
-* Returns the specified config item
-*
-* @access	public
-* @return	mixed
-*/
+ * Returns the specified config item
+ *
+ * @return	mixed
+ */
 if ( ! function_exists('config_item'))
 {
 	function config_item($item)
@@ -302,17 +296,16 @@
 // ------------------------------------------------------------------------
 
 /**
-* Error Handler
-*
-* This function lets us invoke the exception class and
-* display errors using the standard error template located
-* in application/errors/errors.php
-* This function will send the error page directly to the
-* browser and exit.
-*
-* @access	public
-* @return	void
-*/
+ * Error Handler
+ *
+ * This function lets us invoke the exception class and
+ * display errors using the standard error template located
+ * in application/errors/errors.php
+ * This function will send the error page directly to the
+ * browser and exit.
+ *
+ * @return	void
+ */
 if ( ! function_exists('show_error'))
 {
 	function show_error($message, $status_code = 500, $heading = 'An Error Was Encountered')
@@ -326,15 +319,14 @@
 // ------------------------------------------------------------------------
 
 /**
-* 404 Page Handler
-*
-* This function is similar to the show_error() function above
-* However, instead of the standard error template it displays
-* 404 errors.
-*
-* @access	public
-* @return	void
-*/
+ * 404 Page Handler
+ *
+ * This function is similar to the show_error() function above
+ * However, instead of the standard error template it displays
+ * 404 errors.
+ *
+ * @return	void
+ */
 if ( ! function_exists('show_404'))
 {
 	function show_404($page = '', $log_error = TRUE)
@@ -348,14 +340,13 @@
 // ------------------------------------------------------------------------
 
 /**
-* Error Logging Interface
-*
-* We use this as a simple mechanism to access the logging
-* class and send messages to be logged.
-*
-* @access	public
-* @return	void
-*/
+ * Error Logging Interface
+ *
+ * We use this as a simple mechanism to access the logging
+ * class and send messages to be logged.
+ *
+ * @return	void
+ */
 if ( ! function_exists('log_message'))
 {
 	function log_message($level = 'error', $message, $php_error = FALSE)
@@ -377,7 +368,6 @@
 /**
  * Set HTTP Status Header
  *
- * @access	public
  * @param	int		the status code
  * @param	string
  * @return	void
@@ -464,19 +454,18 @@
 // --------------------------------------------------------------------
 
 /**
-* Exception Handler
-*
-* This is the custom exception handler that is declaired at the top
-* of Codeigniter.php.  The main reason we use this is to permit
-* PHP errors to be logged in our own log files since the user may
-* not have access to server logs. Since this function
-* effectively intercepts PHP errors, however, we also need
-* to display errors based on the current error_reporting level.
-* We do that with the use of a PHP error template.
-*
-* @access	private
-* @return	void
-*/
+ * Exception Handler
+ *
+ * This is the custom exception handler that is declaired at the top
+ * of Codeigniter.php.  The main reason we use this is to permit
+ * PHP errors to be logged in our own log files since the user may
+ * not have access to server logs. Since this function
+ * effectively intercepts PHP errors, however, we also need
+ * to display errors based on the current error_reporting level.
+ * We do that with the use of a PHP error template.
+ *
+ * @return	void
+ */
 if ( ! function_exists('_exception_handler'))
 {
 	function _exception_handler($severity, $message, $filepath, $line)
@@ -518,7 +507,6 @@
  * This prevents sandwiching null characters
  * between ascii characters, like Java\0script.
  *
- * @access	public
  * @param	string
  * @return	string
  */
@@ -552,12 +540,11 @@
 // ------------------------------------------------------------------------
 
 /**
-* Returns HTML escaped variable
-*
-* @access	public
-* @param	mixed
-* @return	mixed
-*/
+ * Returns HTML escaped variable
+ *
+ * @param	mixed
+ * @return	mixed
+ */
 if ( ! function_exists('html_escape'))
 {
 	function html_escape($var)
@@ -566,12 +553,57 @@
 		{
 			return array_map('html_escape', $var);
 		}
-		else
-		{
-			return htmlspecialchars($var, ENT_QUOTES, config_item('charset'));
-		}
+
+		return htmlspecialchars($var, ENT_QUOTES, config_item('charset'));
 	}
 }
 
+// ------------------------------------------------------------------------
+
+/**
+ * Load Environmental config directory files.
+ *
+ * In several places we check to see if the environment is loaded up and if the file
+ * that is being requested lives in said environment. Otherwise load up the file from
+ * the main CI config dir.
+ *
+ * @todo 	Optimize a bit to lessen the file system hits if the file has been loaded.
+ * @param 	string 	filename without extension.  eg:  'config' or 'hooks'
+ * @param 	boolean	whether or not to do a `require_once()` or a simple `include()`
+ * @return 	void
+ */
+ if ( ! function_exists('load_environ_config'))
+ {
+	function load_environ_config($file, $require=FALSE)
+	{
+		if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/'.$file.'.php'))
+		{
+			if ($require)
+			{
+				require_once(APPPATH.'config/'.ENVIRONMENT.'/'.$file.'.php');
+			}
+			else
+			{
+				include(APPPATH.'config/'.ENVIRONMENT.'/'.$file.'.php');
+			}
+			
+			return;
+		}
+
+		if ($require)
+		{
+			require_once(APPPATH.'config/'.$file.'.php');
+		}
+		else
+		{
+			include(APPPATH.'config/'.$file.'.php');
+		}
+		
+		return;
+	}
+ }
+
+// ------------------------------------------------------------------------
+
 /* End of file Common.php */
 /* Location: ./system/core/Common.php */
\ No newline at end of file
diff --git a/system/core/Config.php b/system/core/Config.php
index abd2767..b0b4c9a 100755
--- a/system/core/Config.php
+++ b/system/core/Config.php
@@ -328,7 +328,7 @@
 				$uri = $str;
 			}
 		}
-	    return $uri;
+		return $uri;
 	}
 
 	// --------------------------------------------------------------------
diff --git a/system/core/Hooks.php b/system/core/Hooks.php
index 46bfec0..6a36ce9 100755
--- a/system/core/Hooks.php
+++ b/system/core/Hooks.php
@@ -91,16 +91,7 @@
 
 		// Grab the "hooks" definition file.
 		// If there are no hooks, we're done.
-
-		if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/hooks.php'))
-		{
-		    include(APPPATH.'config/'.ENVIRONMENT.'/hooks.php');
-		}
-		elseif (is_file(APPPATH.'config/hooks.php'))
-		{
-			include(APPPATH.'config/hooks.php');
-		}
-
+		load_environ_config('hooks');
 
 		if ( ! isset($hook) OR ! is_array($hook))
 		{
diff --git a/system/core/Loader.php b/system/core/Loader.php
index 4e14b54..83d134e 100644
--- a/system/core/Loader.php
+++ b/system/core/Loader.php
@@ -495,6 +495,20 @@
 	// --------------------------------------------------------------------
 
 	/**
+	 * Get Variables
+	 *
+	 * Retrieve all loaded variables
+	 *
+	 * @return	array
+	 */
+	public function get_vars()
+	{
+		return $this->_ci_cached_vars;
+	}
+
+	// --------------------------------------------------------------------
+
+	/**
 	 * Load Helper
 	 *
 	 * This function loads the specified helper file.
@@ -1125,14 +1139,7 @@
 	 */
 	protected function _ci_autoloader()
 	{
-		if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/autoload.php'))
-		{
-			include(APPPATH.'config/'.ENVIRONMENT.'/autoload.php');
-		}
-		else
-		{
-			include(APPPATH.'config/autoload.php');
-		}
+		load_environ_config('autoload');
 
 		if ( ! isset($autoload))
 		{
diff --git a/system/core/Output.php b/system/core/Output.php
index 7b53f8e..4d1036c 100755
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -106,15 +106,7 @@
 		$this->_zlib_oc = @ini_get('zlib.output_compression');
 
 		// Get mime types for later
-		if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
-		{
-		    include APPPATH.'config/'.ENVIRONMENT.'/mimes.php';
-		}
-		else
-		{
-			include APPPATH.'config/mimes.php';
-		}
-
+		load_environ_config('mimes');
 
 		$this->mime_types = $mimes;
 
diff --git a/system/core/Router.php b/system/core/Router.php
index 748678d..5388a92 100755
--- a/system/core/Router.php
+++ b/system/core/Router.php
@@ -141,14 +141,7 @@
 		}
 
 		// Load the routes.php file.
-		if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/routes.php'))
-		{
-			include(APPPATH.'config/'.ENVIRONMENT.'/routes.php');
-		}
-		elseif (is_file(APPPATH.'config/routes.php'))
-		{
-			include(APPPATH.'config/routes.php');
-		}
+		load_environ_config('routes');
 
 		$this->routes = ( ! isset($route) OR ! is_array($route)) ? array() : $route;
 		unset($route);
diff --git a/system/core/Security.php b/system/core/Security.php
index ce3f7d3..60a64f3 100755
--- a/system/core/Security.php
+++ b/system/core/Security.php
@@ -182,7 +182,7 @@
 
 		// Nothing should last forever
 		unset($_COOKIE[$this->_csrf_cookie_name]);
-                $this->_csrf_hash = '';
+		$this->_csrf_hash = '';
 		$this->_csrf_set_hash();
 		$this->csrf_set_cookie();
 
diff --git a/system/core/Utf8.php b/system/core/Utf8.php
index 7abe4e4..1bcf526 100644
--- a/system/core/Utf8.php
+++ b/system/core/Utf8.php
@@ -44,19 +44,18 @@
 	 * Constructor
 	 *
 	 * Determines if UTF-8 support is to be enabled
-	 *
 	 */
-	function __construct()
+	public function __construct()
 	{
 		log_message('debug', "Utf8 Class Initialized");
 
 		global $CFG;
 
 		if (
-			preg_match('/./u', 'é') === 1					// PCRE must support UTF-8
-			AND function_exists('iconv')					// iconv must be installed
-			AND ini_get('mbstring.func_overload') != 1		// Multibyte string function overloading cannot be enabled
-			AND $CFG->item('charset') == 'UTF-8'			// Application charset must be UTF-8
+			@preg_match('/./u', 'é') === 1		// PCRE must support UTF-8
+			&& function_exists('iconv')			// iconv must be installed
+			&& ini_get('mbstring.func_overload') !== 1	// Multibyte string function overloading cannot be enabled
+			&& $CFG->item('charset') == 'UTF-8'			// Application charset must be UTF-8
 			)
 		{
 			log_message('debug', "UTF-8 Support Enabled");
@@ -90,11 +89,10 @@
 	 *
 	 * Ensures strings are UTF-8
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	string
 	 */
-	function clean_string($str)
+	public function clean_string($str)
 	{
 		if ($this->_is_ascii($str) === FALSE)
 		{
@@ -113,11 +111,10 @@
 	 * line feeds, and carriage returns, as all others can cause
 	 * problems in XML
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	string
 	 */
-	function safe_ascii_for_xml($str)
+	public function safe_ascii_for_xml($str)
 	{
 		return remove_invisible_characters($str, FALSE);
 	}
@@ -129,12 +126,11 @@
 	 *
 	 * Attempts to convert a string to UTF-8
 	 *
-	 * @access	public
 	 * @param	string
 	 * @param	string	- input encoding
 	 * @return	string
 	 */
-	function convert_to_utf8($str, $encoding)
+	public function convert_to_utf8($str, $encoding)
 	{
 		if (function_exists('iconv'))
 		{
@@ -159,13 +155,12 @@
 	 *
 	 * Tests if a string is standard 7-bit ASCII or not
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	bool
 	 */
-	function _is_ascii($str)
+	protected function _is_ascii($str)
 	{
-		return (preg_match('/[^\x00-\x7F]/S', $str) == 0);
+		return (preg_match('/[^\x00-\x7F]/S', $str) === 0);
 	}
 
 	// --------------------------------------------------------------------
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php
index 41950e7..530b44e 100644
--- a/system/database/DB_active_rec.php
+++ b/system/database/DB_active_rec.php
@@ -75,7 +75,7 @@
 	protected $ar_cache_set			= array();
 	
 	protected $ar_no_escape 		= array();
-	protected $ar_cache_no_escape    = array();
+	protected $ar_cache_no_escape	= array();
 
 	// --------------------------------------------------------------------
 
@@ -830,9 +830,10 @@
 	 *
 	 * @param	string
 	 * @param	string	direction: asc or desc
+	 * @param	bool	enable field name escaping
 	 * @return	object
 	 */
-	public function order_by($orderby, $direction = '')
+	public function order_by($orderby, $direction = '', $escape = TRUE)
 	{
 		if (strtolower($direction) == 'random')
 		{
@@ -845,7 +846,7 @@
 		}
 
 
-		if (strpos($orderby, ',') !== FALSE)
+		if ((strpos($orderby, ',') !== FALSE) && ($escape === TRUE))
 		{
 			$temp = array();
 			foreach (explode(',', $orderby) as $part)
@@ -863,7 +864,10 @@
 		}
 		else if ($direction != $this->_random_keyword)
 		{
-			$orderby = $this->_protect_identifiers($orderby);
+			if ($escape === TRUE)
+			{
+				$orderby = $this->_protect_identifiers($orderby);
+			}
 		}
 
 		$orderby_statement = $orderby.$direction;
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index 190b86b..9c38dcb 100644
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -661,11 +661,10 @@
 	 *
 	 * Generates a platform-specific insert string from the supplied data
 	 *
-	 * @access      protected
-	 * @param       string  the table name
-	 * @param       array   the insert keys
-	 * @param       array   the insert values
-	 * @return      string
+	 * @param	string  the table name
+	 * @param	array   the insert keys
+	 * @param 	array   the insert values
+	 * @return 	string
 	 */
 	protected function _insert_batch($table, $keys, $values)
 	{
diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php
index 3ec71a9..f325592 100644
--- a/system/database/drivers/oci8/oci8_result.php
+++ b/system/database/drivers/oci8/oci8_result.php
@@ -57,11 +57,11 @@
 		if ($this->num_rows === 0 && count($this->result_array()) > 0)
 		{
 			$this->num_rows = count($this->result_array());
-			@oci_execute($this->stmt_id);
+			@oci_execute($this->stmt_id, OCI_DEFAULT);
 
 			if ($this->curs_id)
 			{
-				@oci_execute($this->curs_id);
+				@oci_execute($this->curs_id, OCI_DEFAULT);
 			}
 		}
 
diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php
index df0338e..f86ba2d 100644
--- a/system/database/drivers/postgre/postgre_forge.php
+++ b/system/database/drivers/postgre/postgre_forge.php
@@ -225,9 +225,6 @@
 
 	/**
 	 * Drop Table
-	 *
-	 * @access    private
-	 * @return    bool
 	 */
 	function _drop_table($table)
 	{
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
index 0f9f578..340cd3a 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_driver.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -98,7 +98,7 @@
 	 */
 	function db_pconnect()
 	{
-		$this->db_connect(TRUE);
+		return $this->db_connect(TRUE);
 	}
 
 	// --------------------------------------------------------------------
diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php
index 5f5d1aa..3173c98 100644
--- a/system/helpers/download_helper.php
+++ b/system/helpers/download_helper.php
@@ -70,14 +70,7 @@
 		$extension = end($x);
 
 		// Load the mime types
-		if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
-		{
-			include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php');
-		}
-		elseif (is_file(APPPATH.'config/mimes.php'))
-		{
-			include(APPPATH.'config/mimes.php');
-		}
+		load_environ_config('mimes');
 
 		// Set a default mime if we can't find it
 		if ( ! isset($mimes[$extension]))
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index 5b50853..b4edcde 100644
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -364,14 +364,7 @@
 
 		if ( ! is_array($mimes))
 		{
-			if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
-			{
-				include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php');
-			}
-			elseif (is_file(APPPATH.'config/mimes.php'))
-			{
-				include(APPPATH.'config/mimes.php');
-			}
+			load_environ_config('mimes');
 
 			if ( ! is_array($mimes))
 			{
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index b6bb402..fa805f1 100644
--- a/system/helpers/html_helper.php
+++ b/system/helpers/html_helper.php
@@ -275,14 +275,7 @@
 
 		if ( ! is_array($_doctypes))
 		{
-			if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php'))
-			{
-				include(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php');
-			}
-			elseif (is_file(APPPATH.'config/doctypes.php'))
-			{
-				include(APPPATH.'config/doctypes.php');
-			}
+			load_environ_config('doctypes');
 
 			if ( ! is_array($_doctypes))
 			{
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
index 3393bda..7c50821 100644
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -56,33 +56,33 @@
 		$result = strval($str);
 
 		$singular_rules = array(
-			'/(matr)ices$/'         => '\1ix',
-			'/(vert|ind)ices$/'     => '\1ex',
-			'/^(ox)en/'             => '\1',
-			'/(alias)es$/'          => '\1',
-			'/([octop|vir])i$/'     => '\1us',
-			'/(cris|ax|test)es$/'   => '\1is',
-			'/(shoe)s$/'            => '\1',
-			'/(o)es$/'              => '\1',
-			'/(bus|campus)es$/'     => '\1',
-			'/([m|l])ice$/'         => '\1ouse',
-			'/(x|ch|ss|sh)es$/'     => '\1',
-			'/(m)ovies$/'           => '\1\2ovie',
-			'/(s)eries$/'           => '\1\2eries',
-			'/([^aeiouy]|qu)ies$/'  => '\1y',
-			'/([lr])ves$/'          => '\1f',
-			'/(tive)s$/'            => '\1',
-			'/(hive)s$/'            => '\1',
-			'/([^f])ves$/'          => '\1fe',
-			'/(^analy)ses$/'        => '\1sis',
+			'/(matr)ices$/'			=> '\1ix',
+			'/(vert|ind)ices$/'		=> '\1ex',
+			'/^(ox)en/'				=> '\1',
+			'/(alias)es$/'			=> '\1',
+			'/([octop|vir])i$/'		=> '\1us',
+			'/(cris|ax|test)es$/'	=> '\1is',
+			'/(shoe)s$/'			=> '\1',
+			'/(o)es$/'				=> '\1',
+			'/(bus|campus)es$/'		=> '\1',
+			'/([m|l])ice$/'			=> '\1ouse',
+			'/(x|ch|ss|sh)es$/'		=> '\1',
+			'/(m)ovies$/'			=> '\1\2ovie',
+			'/(s)eries$/'			=> '\1\2eries',
+			'/([^aeiouy]|qu)ies$/'	=> '\1y',
+			'/([lr])ves$/'			=> '\1f',
+			'/(tive)s$/'			=> '\1',
+			'/(hive)s$/'			=> '\1',
+			'/([^f])ves$/'			=> '\1fe',
+			'/(^analy)ses$/'		=> '\1sis',
 			'/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/' => '\1\2sis',
-			'/([ti])a$/'            => '\1um',
-			'/(p)eople$/'           => '\1\2erson',
-			'/(m)en$/'              => '\1an',
-			'/(s)tatuses$/'         => '\1\2tatus',
-			'/(c)hildren$/'         => '\1\2hild',
-			'/(n)ews$/'             => '\1\2ews',
-			'/([^u])s$/'            => '\1',
+			'/([ti])a$/'			=> '\1um',
+			'/(p)eople$/'			=> '\1\2erson',
+			'/(m)en$/'				=> '\1an',
+			'/(s)tatuses$/'			=> '\1\2tatus',
+			'/(c)hildren$/'			=> '\1\2hild',
+			'/(n)ews$/'				=> '\1\2ews',
+			'/([^u])s$/'			=> '\1',
 		);
 
 		foreach ($singular_rules as $rule => $replacement)
@@ -117,25 +117,25 @@
 		$result = strval($str);
 
 		$plural_rules = array(
-			'/^(ox)$/'                 => '\1\2en',     // ox
-			'/([m|l])ouse$/'           => '\1ice',      // mouse, louse
-			'/(matr|vert|ind)ix|ex$/'  => '\1ices',     // matrix, vertex, index
-			'/(x|ch|ss|sh)$/'          => '\1es',       // search, switch, fix, box, process, address
-			'/([^aeiouy]|qu)y$/'       => '\1ies',      // query, ability, agency
-			'/(hive)$/'                => '\1s',        // archive, hive
-			'/(?:([^f])fe|([lr])f)$/'  => '\1\2ves',    // half, safe, wife
-			'/sis$/'                   => 'ses',        // basis, diagnosis
-			'/([ti])um$/'              => '\1a',        // datum, medium
-			'/(p)erson$/'              => '\1eople',    // person, salesperson
-			'/(m)an$/'                 => '\1en',       // man, woman, spokesman
-			'/(c)hild$/'               => '\1hildren',  // child
-			'/(buffal|tomat)o$/'       => '\1\2oes',    // buffalo, tomato
-			'/(bu|campu)s$/'           => '\1\2ses',    // bus, campus
-			'/(alias|status|virus)/'   => '\1es',       // alias
-			'/(octop)us$/'             => '\1i',        // octopus
-			'/(ax|cris|test)is$/'      => '\1es',       // axis, crisis
-			'/s$/'                     => 's',          // no change (compatibility)
-			'/$/'                      => 's',
+			'/^(ox)$/'					=> '\1\2en',	 // ox
+			'/([m|l])ouse$/'			=> '\1ice',	  // mouse, louse
+			'/(matr|vert|ind)ix|ex$/'	=> '\1ices',	 // matrix, vertex, index
+			'/(x|ch|ss|sh)$/'			=> '\1es',	   // search, switch, fix, box, process, address
+			'/([^aeiouy]|qu)y$/'		=> '\1ies',	  // query, ability, agency
+			'/(hive)$/'					=> '\1s',		// archive, hive
+			'/(?:([^f])fe|([lr])f)$/'	=> '\1\2ves',	// half, safe, wife
+			'/sis$/'					=> 'ses',		// basis, diagnosis
+			'/([ti])um$/'				=> '\1a',		// datum, medium
+			'/(p)erson$/'				=> '\1eople',	// person, salesperson
+			'/(m)an$/'					=> '\1en',	   // man, woman, spokesman
+			'/(c)hild$/'				=> '\1hildren',  // child
+			'/(buffal|tomat)o$/'		=> '\1\2oes',	// buffalo, tomato
+			'/(bu|campu)s$/'			=> '\1\2ses',	// bus, campus
+			'/(alias|status|virus)/'	=> '\1es',	   // alias
+			'/(octop)us$/'				=> '\1i',		// octopus
+			'/(ax|cris|test)is$/'		=> '\1es',	   // axis, crisis
+			'/s$/'						=> 's',		  // no change (compatibility)
+			'/$/'						=> 's',
 		);
 
 		foreach ($plural_rules as $rule => $replacement)
diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php
index 991495e..e04d5d6 100644
--- a/system/helpers/smiley_helper.php
+++ b/system/helpers/smiley_helper.php
@@ -241,14 +241,7 @@
 {
 	function _get_smiley_array()
 	{
-		if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'))
-		{
-		    include(APPPATH.'config/'.ENVIRONMENT.'/smileys.php');
-		}
-		elseif (file_exists(APPPATH.'config/smileys.php'))
-		{
-			include(APPPATH.'config/smileys.php');
-		}
+		load_environ_config('smileys');
 		
 		if (isset($smileys) AND is_array($smileys))
 		{
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 38b46e2..7a4a689 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -378,14 +378,7 @@
 {
 	function convert_accented_characters($str)
 	{
-		if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'))
-		{
-			include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php');
-		}
-		elseif (is_file(APPPATH.'config/foreign_chars.php'))
-		{
-			include(APPPATH.'config/foreign_chars.php');
-		}
+		load_environ_config('foreign_chars');
 
 		if ( ! isset($foreign_characters))
 		{
diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php
index 269bf9b..8725373 100644
--- a/system/libraries/Cache/Cache.php
+++ b/system/libraries/Cache/Cache.php
@@ -1,13 +1,13 @@
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 /**
  * CodeIgniter
  *
  * An open source application development framework for PHP 5.1.6 or newer
  *
  * NOTICE OF LICENSE
- * 
+ *
  * Licensed under the Open Software License version 3.0
- * 
+ *
  * This source file is subject to the Open Software License (OSL 3.0) that is
  * bundled with this package in the files license.txt / license.rst.  It is
  * also available through the world wide web at this URL:
@@ -22,22 +22,22 @@
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 2.0
- * @filesource	
+ * @filesource
  */
 
 // ------------------------------------------------------------------------
 
 /**
- * CodeIgniter Caching Class 
+ * CodeIgniter Caching Class
  *
  * @package		CodeIgniter
  * @subpackage	Libraries
  * @category	Core
  * @author		EllisLab Dev Team
- * @link		
+ * @link
  */
 class CI_Cache extends CI_Driver_Library {
-	
+
 	protected $valid_drivers 	= array(
 		'cache_apc', 'cache_file', 'cache_memcached', 'cache_dummy'
 	);
@@ -45,7 +45,7 @@
 	protected $_cache_path		= NULL;		// Path of cache files (if file-based cache)
 	protected $_adapter			= 'dummy';
 	protected $_backup_driver;
-	
+
 	// ------------------------------------------------------------------------
 
 	/**
@@ -64,16 +64,16 @@
 	// ------------------------------------------------------------------------
 
 	/**
-	 * Get 
+	 * Get
 	 *
-	 * Look for a value in the cache.  If it exists, return the data 
+	 * Look for a value in the cache.  If it exists, return the data
 	 * if not, return FALSE
 	 *
-	 * @param 	string	
+	 * @param 	string
 	 * @return 	mixed		value that is stored/FALSE on failure
 	 */
 	public function get($id)
-	{	
+	{
 		return $this->{$this->_adapter}->get($id);
 	}
 
@@ -124,7 +124,7 @@
 	 * Cache Info
 	 *
 	 * @param 	string		user/filehits
-	 * @return 	mixed		array on success, false on failure	
+	 * @return 	mixed		array on success, false on failure
 	 */
 	public function cache_info($type = 'user')
 	{
@@ -132,7 +132,7 @@
 	}
 
 	// ------------------------------------------------------------------------
-	
+
 	/**
 	 * Get Cache Metadata
 	 *
@@ -143,7 +143,7 @@
 	{
 		return $this->{$this->_adapter}->get_metadata($id);
 	}
-	
+
 	// ------------------------------------------------------------------------
 
 	/**
@@ -151,11 +151,11 @@
 	 *
 	 * Initialize class properties based on the configuration array.
 	 *
-	 * @param	array 	
+	 * @param	array
 	 * @return 	void
 	 */
 	private function _initialize($config)
-	{        
+	{
 		$default_config = array(
 				'adapter',
 				'memcached'
@@ -219,10 +219,10 @@
 
 		return $obj;
 	}
-	
+
 	// ------------------------------------------------------------------------
 }
 // End Class
 
 /* End of file Cache.php */
-/* Location: ./system/libraries/Cache/Cache.php */
\ No newline at end of file
+/* Location: ./system/libraries/Cache/Cache.php */
diff --git a/system/libraries/Cache/drivers/Cache_apc.php b/system/libraries/Cache/drivers/Cache_apc.php
index f15cf85..90b6868 100644
--- a/system/libraries/Cache/drivers/Cache_apc.php
+++ b/system/libraries/Cache/drivers/Cache_apc.php
@@ -1,13 +1,13 @@
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 /**
  * CodeIgniter
  *
  * An open source application development framework for PHP 5.1.6 or newer
  *
  * NOTICE OF LICENSE
- * 
+ *
  * Licensed under the Open Software License version 3.0
- * 
+ *
  * This source file is subject to the Open Software License (OSL 3.0) that is
  * bundled with this package in the files license.txt / license.rst.  It is
  * also available through the world wide web at this URL:
@@ -22,30 +22,30 @@
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 2.0
- * @filesource	
+ * @filesource
  */
 
 // ------------------------------------------------------------------------
 
 /**
- * CodeIgniter APC Caching Class 
+ * CodeIgniter APC Caching Class
  *
  * @package		CodeIgniter
  * @subpackage	Libraries
  * @category	Core
  * @author		EllisLab Dev Team
- * @link		
+ * @link
  */
 
 class CI_Cache_apc extends CI_Driver {
 
 	/**
-	 * Get 
+	 * Get
 	 *
-	 * Look for a value in the cache.  If it exists, return the data 
+	 * Look for a value in the cache.  If it exists, return the data
 	 * if not, return FALSE
 	 *
-	 * @param 	string	
+	 * @param 	string
 	 * @return 	mixed		value that is stored/FALSE on failure
 	 */
 	public function get($id)
@@ -55,8 +55,8 @@
 		return (is_array($data)) ? $data[0] : FALSE;
 	}
 
-	// ------------------------------------------------------------------------	
-	
+	// ------------------------------------------------------------------------
+
 	/**
 	 * Cache Save
 	 *
@@ -70,7 +70,7 @@
 	{
 		return apc_store($id, array($data, time(), $ttl), $ttl);
 	}
-	
+
 	// ------------------------------------------------------------------------
 
 	/**
@@ -102,7 +102,7 @@
 	 * Cache Info
 	 *
 	 * @param 	string		user/filehits
-	 * @return 	mixed		array on success, false on failure	
+	 * @return 	mixed		array on success, false on failure
 	 */
 	 public function cache_info($type = NULL)
 	 {
@@ -149,13 +149,13 @@
 			log_message('error', 'The APC PHP extension must be loaded to use APC Cache.');
 			return FALSE;
 		}
-		
+
 		return TRUE;
 	}
 
 	// ------------------------------------------------------------------------
 
-	
+
 }
 // End Class
 
diff --git a/system/libraries/Cache/drivers/Cache_dummy.php b/system/libraries/Cache/drivers/Cache_dummy.php
index 965bb2b..ff787e9 100644
--- a/system/libraries/Cache/drivers/Cache_dummy.php
+++ b/system/libraries/Cache/drivers/Cache_dummy.php
@@ -1,13 +1,13 @@
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 /**
  * CodeIgniter
  *
  * An open source application development framework for PHP 5.1.6 or newer
  *
  * NOTICE OF LICENSE
- * 
+ *
  * Licensed under the Open Software License version 3.0
- * 
+ *
  * This source file is subject to the Open Software License (OSL 3.0) that is
  * bundled with this package in the files license.txt / license.rst.  It is
  * also available through the world wide web at this URL:
@@ -138,4 +138,4 @@
 // End Class
 
 /* End of file Cache_dummy.php */
-/* Location: ./system/libraries/Cache/drivers/Cache_dummy.php */
\ No newline at end of file
+/* Location: ./system/libraries/Cache/drivers/Cache_dummy.php */
diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php
index be392d3..1942797 100644
--- a/system/libraries/Cache/drivers/Cache_file.php
+++ b/system/libraries/Cache/drivers/Cache_file.php
@@ -1,13 +1,13 @@
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 /**
  * CodeIgniter
  *
  * An open source application development framework for PHP 5.1.6 or newer
  *
  * NOTICE OF LICENSE
- * 
+ *
  * Licensed under the Open Software License version 3.0
- * 
+ *
  * This source file is subject to the Open Software License (OSL 3.0) that is
  * bundled with this package in the files license.txt / license.rst.  It is
  * also available through the world wide web at this URL:
@@ -22,19 +22,19 @@
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 2.0
- * @filesource	
+ * @filesource
  */
 
 // ------------------------------------------------------------------------
 
 /**
- * CodeIgniter Memcached Caching Class 
+ * CodeIgniter Memcached Caching Class
  *
  * @package		CodeIgniter
  * @subpackage	Libraries
  * @category	Core
  * @author		EllisLab Dev Team
- * @link		
+ * @link
  */
 
 class CI_Cache_file extends CI_Driver {
@@ -48,9 +48,7 @@
 	{
 		$CI =& get_instance();
 		$CI->load->helper('file');
-		
 		$path = $CI->config->item('cache_path');
-	
 		$this->_cache_path = ($path == '') ? APPPATH.'cache/' : $path;
 	}
 
@@ -68,16 +66,15 @@
 		{
 			return FALSE;
 		}
-		
-		$data = read_file($this->_cache_path.$id);
-		$data = unserialize($data);
-		
+
+		$data = unserialize(read_file($this->_cache_path.$id));
+
 		if (time() >  $data['time'] + $data['ttl'])
 		{
 			unlink($this->_cache_path.$id);
 			return FALSE;
 		}
-		
+
 		return $data['data'];
 	}
 
@@ -88,22 +85,22 @@
 	 *
 	 * @param 	string		unique key
 	 * @param 	mixed		data to store
-	 * @param 	int			length of time (in seconds) the cache is valid 
+	 * @param 	int			length of time (in seconds) the cache is valid
 	 *						- Default is 60 seconds
 	 * @return 	boolean		true on success/false on failure
 	 */
 	public function save($id, $data, $ttl = 60)
-	{		
+	{
 		$contents = array(
 				'time'		=> time(),
-				'ttl'		=> $ttl,			
+				'ttl'		=> $ttl,
 				'data'		=> $data
 			);
-		
+
 		if (write_file($this->_cache_path.$id, serialize($contents)))
 		{
 			@chmod($this->_cache_path.$id, 0777);
-			return TRUE;			
+			return TRUE;
 		}
 
 		return FALSE;
@@ -119,14 +116,7 @@
 	 */
 	public function delete($id)
 	{
-		if (file_exists($this->_cache_path.$id))
-		{
-			return unlink($this->_cache_path.$id);
-		}
-		else
-		{
-			return FALSE;
-		}
+		return (file_exists($this->_cache_path.$id)) ? unlink($this->_cache_path.$id) : FALSE;
 	}
 
 	// ------------------------------------------------------------------------
@@ -135,7 +125,7 @@
 	 * Clean the Cache
 	 *
 	 * @return 	boolean		false on failure/true on success
-	 */	
+	 */
 	public function clean()
 	{
 		return delete_files($this->_cache_path);
@@ -170,10 +160,9 @@
 		{
 			return FALSE;
 		}
-		
-		$data = read_file($this->_cache_path.$id);		
-		$data = unserialize($data);
-		
+
+		$data = unserialize(read_file($this->_cache_path.$id));
+
 		if (is_array($data))
 		{
 			$mtime = filemtime($this->_cache_path.$id);
@@ -188,7 +177,7 @@
 				'mtime'	 => $mtime
 			);
 		}
-		
+
 		return FALSE;
 	}
 
@@ -198,7 +187,7 @@
 	 * Is supported
 	 *
 	 * In the file driver, check to see that the cache directory is indeed writable
-	 * 
+	 *
 	 * @return boolean
 	 */
 	public function is_supported()
diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php
index 78cab25..0037e67 100644
--- a/system/libraries/Cache/drivers/Cache_memcached.php
+++ b/system/libraries/Cache/drivers/Cache_memcached.php
@@ -1,13 +1,13 @@
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 /**
  * CodeIgniter
  *
  * An open source application development framework for PHP 5.1.6 or newer
  *
  * NOTICE OF LICENSE
- * 
+ *
  * Licensed under the Open Software License version 3.0
- * 
+ *
  * This source file is subject to the Open Software License (OSL 3.0) that is
  * bundled with this package in the files license.txt / license.rst.  It is
  * also available through the world wide web at this URL:
@@ -84,7 +84,7 @@
 		{
 			return $this->_memcached->set($id, array($data, time(), $ttl), 0, $ttl);
 		}
-		
+
 		return FALSE;
 	}
 
@@ -256,4 +256,4 @@
 // End Class
 
 /* End of file Cache_memcached.php */
-/* Location: ./system/libraries/Cache/drivers/Cache_memcached.php */
\ No newline at end of file
+/* Location: ./system/libraries/Cache/drivers/Cache_memcached.php */
diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php
index f5ef4d5..605765b 100644
--- a/system/libraries/Calendar.php
+++ b/system/libraries/Calendar.php
@@ -1,13 +1,13 @@
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 /**
  * CodeIgniter
  *
  * An open source application development framework for PHP 5.1.6 or newer
  *
  * NOTICE OF LICENSE
- * 
+ *
  * Licensed under the Open Software License version 3.0
- * 
+ *
  * This source file is subject to the Open Software License (OSL 3.0) that is
  * bundled with this package in the files license.txt / license.rst.  It is
  * also available through the world wide web at this URL:
@@ -40,15 +40,15 @@
  */
 class CI_Calendar {
 
-	var $CI;
-	var $lang;
-	var $local_time;
-	var $template		= '';
-	var $start_day		= 'sunday';
-	var $month_type		= 'long';
-	var $day_type		= 'abr';
-	var $show_next_prev	= FALSE;
-	var $next_prev_url	= '';
+	private $CI;
+	public $lang;
+	public $local_time;
+	public $template		= '';
+	public $start_day		= 'sunday';
+	public $month_type		= 'long';
+	public $day_type		= 'abr';
+	public $show_next_prev	= FALSE;
+	public $next_prev_url	= '';
 
 	/**
 	 * Constructor
@@ -85,7 +85,7 @@
 	 * @param	array	config preferences
 	 * @return	void
 	 */
-	function initialize($config = array())
+	public function initialize($config = array())
 	{
 		foreach ($config as $key => $val)
 		{
@@ -107,23 +107,30 @@
 	 * @param	array	the data to be shown in the calendar cells
 	 * @return	string
 	 */
-	function generate($year = '', $month = '', $data = array())
+	public function generate($year = '', $month = '', $data = array())
 	{
 		// Set and validate the supplied month/year
 		if ($year == '')
-			$year  = date("Y", $this->local_time);
+		{
+			$year  = date('Y', $this->local_time);
+		}
+		elseif (strlen($year) === 1)
+		{
+			$year = '200'.$year;
+		}
+		elseif (strlen($year) === 2)
+		{
+			$year = '20'.$year;
+		}
 
 		if ($month == '')
-			$month = date("m", $this->local_time);
-
-		if (strlen($year) == 1)
-			$year = '200'.$year;
-
-		if (strlen($year) == 2)
-			$year = '20'.$year;
-
-		if (strlen($month) == 1)
+		{
+			$month = date('m', $this->local_time);
+		}
+		elseif (strlen($month) === 1)
+		{
 			$month = '0'.$month;
+		}
 
 		$adjusted_date = $this->adjust_date($month, $year);
 
@@ -149,9 +156,9 @@
 
 		// Set the current month/year/day
 		// We use this to determine the "today" date
-		$cur_year	= date("Y", $this->local_time);
-		$cur_month	= date("m", $this->local_time);
-		$cur_day	= date("j", $this->local_time);
+		$cur_year	= date('Y', $this->local_time);
+		$cur_month	= date('m', $this->local_time);
+		$cur_day	= date('j', $this->local_time);
 
 		$is_current_month = ($cur_year == $year AND $cur_month == $month) ? TRUE : FALSE;
 
@@ -159,12 +166,7 @@
 		$this->parse_template();
 
 		// Begin building the calendar output
-		$out = $this->temp['table_open'];
-		$out .= "\n";
-
-		$out .= "\n";
-		$out .= $this->temp['heading_row_start'];
-		$out .= "\n";
+		$out = $this->temp['table_open']."\n\n".$this->temp['heading_row_start']."\n";
 
 		// "previous" month link
 		if ($this->show_next_prev == TRUE)
@@ -173,18 +175,16 @@
 			$this->next_prev_url = preg_replace("/(.+?)\/*$/", "\\1/",  $this->next_prev_url);
 
 			$adjusted_date = $this->adjust_date($month - 1, $year);
-			$out .= str_replace('{previous_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_previous_cell']);
-			$out .= "\n";
+			$out .= str_replace('{previous_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_previous_cell'])."\n";
 		}
 
 		// Heading containing the month/year
 		$colspan = ($this->show_next_prev == TRUE) ? 5 : 7;
 
-		$this->temp['heading_title_cell'] = str_replace('{colspan}', $colspan, $this->temp['heading_title_cell']);
-		$this->temp['heading_title_cell'] = str_replace('{heading}', $this->get_month_name($month)."&nbsp;".$year, $this->temp['heading_title_cell']);
+		$this->temp['heading_title_cell'] = str_replace('{colspan}', $colspan,
+								str_replace('{heading}', $this->get_month_name($month).'&nbsp;'.$year, $this->temp['heading_title_cell']));
 
-		$out .= $this->temp['heading_title_cell'];
-		$out .= "\n";
+		$out .= $this->temp['heading_title_cell']."\n";
 
 		// "next" month link
 		if ($this->show_next_prev == TRUE)
@@ -193,14 +193,9 @@
 			$out .= str_replace('{next_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_next_cell']);
 		}
 
-		$out .= "\n";
-		$out .= $this->temp['heading_row_end'];
-		$out .= "\n";
-
-		// Write the cells containing the days of the week
-		$out .= "\n";
-		$out .= $this->temp['week_row_start'];
-		$out .= "\n";
+		$out .= "\n".$this->temp['heading_row_end']."\n\n"
+			// Write the cells containing the days of the week
+			.$this->temp['week_row_start']."\n";
 
 		$day_names = $this->get_day_names();
 
@@ -209,33 +204,31 @@
 			$out .= str_replace('{week_day}', $day_names[($start_day + $i) %7], $this->temp['week_day_cell']);
 		}
 
-		$out .= "\n";
-		$out .= $this->temp['week_row_end'];
-		$out .= "\n";
+		$out .= "\n".$this->temp['week_row_end']."\n";
 
 		// Build the main body of the calendar
 		while ($day <= $total_days)
 		{
-			$out .= "\n";
-			$out .= $this->temp['cal_row_start'];
-			$out .= "\n";
+			$out .= "\n".$this->temp['cal_row_start']."\n";
 
 			for ($i = 0; $i < 7; $i++)
 			{
-				$out .= ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start'];
+				$out .= ($is_current_month === TRUE AND $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start'];
 
 				if ($day > 0 AND $day <= $total_days)
 				{
 					if (isset($data[$day]))
 					{
 						// Cells with content
-						$temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content'];
-						$out .= str_replace('{day}', $day, str_replace('{content}', $data[$day], $temp));
+						$temp = ($is_current_month === TRUE AND $day == $cur_day) ?
+								$this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content'];
+						$out .= str_replace(array('{content}', '{day}'), array($data[$day], $day), $temp);
 					}
 					else
 					{
 						// Cells with no content
-						$temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content'];
+						$temp = ($is_current_month === TRUE AND $day == $cur_day) ?
+								$this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content'];
 						$out .= str_replace('{day}', $day, $temp);
 					}
 				}
@@ -245,17 +238,14 @@
 					$out .= $this->temp['cal_cell_blank'];
 				}
 
-				$out .= ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end'];					
+				$out .= ($is_current_month === TRUE AND $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end'];
 				$day++;
 			}
 
-			$out .= "\n";
-			$out .= $this->temp['cal_row_end'];
-			$out .= "\n";
+			$out .= "\n".$this->temp['cal_row_end']."\n";
 		}
 
-		$out .= "\n";
-		$out .= $this->temp['table_close'];
+		$out .= "\n".$this->temp['table_close'];
 
 		return $out;
 	}
@@ -272,7 +262,7 @@
 	 * @param	integer	the month
 	 * @return	string
 	 */
-	function get_month_name($month)
+	public function get_month_name($month)
 	{
 		if ($this->month_type == 'short')
 		{
@@ -287,7 +277,7 @@
 
 		if ($this->CI->lang->line($month) === FALSE)
 		{
-			return ucfirst(str_replace('cal_', '', $month));
+			return ucfirst(substr($month, 4));
 		}
 
 		return $this->CI->lang->line($month);
@@ -305,10 +295,12 @@
 	 * @param	string
 	 * @return	array
 	 */
-	function get_day_names($day_type = '')
+	public function get_day_names($day_type = '')
 	{
 		if ($day_type != '')
+		{
 			$this->day_type = $day_type;
+		}
 
 		if ($this->day_type == 'long')
 		{
@@ -324,9 +316,9 @@
 		}
 
 		$days = array();
-		foreach ($day_names as $val)
+		for ($i = 0, $c = count($day_names); $i < $c; $i++)
 		{
-			$days[] = ($this->CI->lang->line('cal_'.$val) === FALSE) ? ucfirst($val) : $this->CI->lang->line('cal_'.$val);
+			$days[] = ($this->CI->lang->line('cal_'.$day_names[$i]) === FALSE) ? ucfirst($day_names[$i]) : $this->CI->lang->line('cal_'.$day_names[$i]);
 		}
 
 		return $days;
@@ -346,7 +338,7 @@
 	 * @param	integer	the year
 	 * @return	array
 	 */
-	function adjust_date($month, $year)
+	public function adjust_date($month, $year)
 	{
 		$date = array();
 
@@ -365,7 +357,7 @@
 			$date['year']--;
 		}
 
-		if (strlen($date['month']) == 1)
+		if (strlen($date['month']) === 1)
 		{
 			$date['month'] = '0'.$date['month'];
 		}
@@ -383,7 +375,7 @@
 	 * @param	integer	the year
 	 * @return	integer
 	 */
-	function get_total_days($month, $year)
+	public function get_total_days($month, $year)
 	{
 		$days_in_month	= array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
 
@@ -414,7 +406,7 @@
 	 * @access	public
 	 * @return array
 	 */
-	function default_template()
+	public function default_template()
 	{
 		return  array (
 						'table_open'				=> '<table border="0" cellpadding="4" cellspacing="0">',
@@ -452,7 +444,7 @@
 	 * @access	public
 	 * @return	void
 	 */
-	function parse_template()
+	public function parse_template()
 	{
 		$this->temp = $this->default_template();
 
@@ -467,14 +459,11 @@
 		{
 			if (preg_match("/\{".$val."\}(.*?)\{\/".$val."\}/si", $this->template, $match))
 			{
-				$this->temp[$val] = $match['1'];
+				$this->temp[$val] = $match[1];
 			}
-			else
+			elseif (in_array($val, $today, TRUE))
 			{
-				if (in_array($val, $today, TRUE))
-				{
-					$this->temp[$val] = $this->temp[str_replace('_today', '', $val)];
-				}
+				$this->temp[$val] = $this->temp[substr($val, 0, -6)];
 			}
 		}
 	}
@@ -484,4 +473,4 @@
 // END CI_Calendar class
 
 /* End of file Calendar.php */
-/* Location: ./system/libraries/Calendar.php */
\ No newline at end of file
+/* Location: ./system/libraries/Calendar.php */
diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php
index c2cb808..92b0b3c 100644
--- a/system/libraries/Encrypt.php
+++ b/system/libraries/Encrypt.php
@@ -40,22 +40,19 @@
  */
 class CI_Encrypt {
 
-	var $CI;
-	var $encryption_key	= '';
-	var $_hash_type	= 'sha1';
-	var $_mcrypt_exists = FALSE;
-	var $_mcrypt_cipher;
-	var $_mcrypt_mode;
+	public $encryption_key	= '';
+	protected $_hash_type	= 'sha1';
+	protected $_mcrypt_exists = FALSE;
+	protected $_mcrypt_cipher;
+	protected $_mcrypt_mode;
 
 	/**
 	 * Constructor
 	 *
 	 * Simply determines whether the mcrypt library exists.
-	 *
 	 */
 	public function __construct()
 	{
-		$this->CI =& get_instance();
 		$this->_mcrypt_exists = ( ! function_exists('mcrypt_encrypt')) ? FALSE : TRUE;
 		log_message('debug', "Encrypt Class Initialized");
 	}
@@ -68,11 +65,10 @@
 	 * Returns it as MD5 in order to have an exact-length 128 bit key.
 	 * Mcrypt is sensitive to keys that are not the correct length
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	string
 	 */
-	function get_key($key = '')
+	public function get_key($key = '')
 	{
 		if ($key == '')
 		{
@@ -84,7 +80,7 @@
 			$CI =& get_instance();
 			$key = $CI->config->item('encryption_key');
 
-			if ($key == FALSE)
+			if ($key === FALSE)
 			{
 				show_error('In order to use the encryption class requires that you set an encryption key in your config file.');
 			}
@@ -98,13 +94,13 @@
 	/**
 	 * Set the encryption key
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	void
 	 */
-	function set_key($key = '')
+	public function set_key($key = '')
 	{
 		$this->encryption_key = $key;
+		return $this;
 	}
 
 	// --------------------------------------------------------------------
@@ -120,12 +116,11 @@
 	 * that is randomized with each call to this function,
 	 * even if the supplied message and key are the same.
 	 *
-	 * @access	public
 	 * @param	string	the string to encode
 	 * @param	string	the key
 	 * @return	string
 	 */
-	function encode($string, $key = '')
+	public function encode($string, $key = '')
 	{
 		$key = $this->get_key($key);
 
@@ -148,12 +143,11 @@
 	 *
 	 * Reverses the above process
 	 *
-	 * @access	public
 	 * @param	string
 	 * @param	string
 	 * @return	string
 	 */
-	function decode($string, $key = '')
+	public function decode($string, $key = '')
 	{
 		$key = $this->get_key($key);
 
@@ -191,13 +185,12 @@
 	 *
 	 * For more details, see http://codeigniter.com/user_guide/installation/upgrade_200.html#encryption
 	 *
-	 * @access	public
 	 * @param	string
 	 * @param	int		(mcrypt mode constant)
 	 * @param	string
 	 * @return	string
 	 */
-	function encode_from_legacy($string, $legacy_mode = MCRYPT_MODE_ECB, $key = '')
+	public function encode_from_legacy($string, $legacy_mode = MCRYPT_MODE_ECB, $key = '')
 	{
 		if ($this->_mcrypt_exists === FALSE)
 		{
@@ -242,12 +235,11 @@
 	 * Takes a plain-text string and key as input and generates an
 	 * encoded bit-string using XOR
 	 *
-	 * @access	private
 	 * @param	string
 	 * @param	string
 	 * @return	string
 	 */
-	function _xor_encode($string, $key)
+	protected function _xor_encode($string, $key)
 	{
 		$rand = '';
 		while (strlen($rand) < 32)
@@ -274,12 +266,11 @@
 	 * Takes an encoded string and key as input and generates the
 	 * plain-text original message
 	 *
-	 * @access	private
 	 * @param	string
 	 * @param	string
 	 * @return	string
 	 */
-	function _xor_decode($string, $key)
+	protected function _xor_decode($string, $key)
 	{
 		$string = $this->_xor_merge($string, $key);
 
@@ -299,12 +290,11 @@
 	 *
 	 * Takes a string and key as input and computes the difference using XOR
 	 *
-	 * @access	private
 	 * @param	string
 	 * @param	string
 	 * @return	string
 	 */
-	function _xor_merge($string, $key)
+	protected function _xor_merge($string, $key)
 	{
 		$hash = $this->hash($key);
 		$str = '';
@@ -321,12 +311,11 @@
 	/**
 	 * Encrypt using Mcrypt
 	 *
-	 * @access	public
 	 * @param	string
 	 * @param	string
 	 * @return	string
 	 */
-	function mcrypt_encode($data, $key)
+	public function mcrypt_encode($data, $key)
 	{
 		$init_size = mcrypt_get_iv_size($this->_get_cipher(), $this->_get_mode());
 		$init_vect = mcrypt_create_iv($init_size, MCRYPT_RAND);
@@ -338,12 +327,11 @@
 	/**
 	 * Decrypt using Mcrypt
 	 *
-	 * @access	public
 	 * @param	string
 	 * @param	string
 	 * @return	string
 	 */
-	function mcrypt_decode($data, $key)
+	public function mcrypt_decode($data, $key)
 	{
 		$data = $this->_remove_cipher_noise($data, $key);
 		$init_size = mcrypt_get_iv_size($this->_get_cipher(), $this->_get_mode());
@@ -365,14 +353,11 @@
 	 * against Man-in-the-middle attacks on CBC mode ciphers
 	 * http://www.ciphersbyritter.com/GLOSSARY.HTM#IV
 	 *
-	 * Function description
-	 *
-	 * @access	private
 	 * @param	string
 	 * @param	string
 	 * @return	string
 	 */
-	function _add_cipher_noise($data, $key)
+	protected function _add_cipher_noise($data, $key)
 	{
 		$keyhash = $this->hash($key);
 		$keylen = strlen($keyhash);
@@ -399,11 +384,10 @@
 	 *
 	 * Function description
 	 *
-	 * @access	public
 	 * @param	type
 	 * @return	type
 	 */
-	function _remove_cipher_noise($data, $key)
+	protected function _remove_cipher_noise($data, $key)
 	{
 		$keyhash = $this->hash($key);
 		$keylen = strlen($keyhash);
@@ -434,13 +418,13 @@
 	/**
 	 * Set the Mcrypt Cipher
 	 *
-	 * @access	public
 	 * @param	constant
 	 * @return	string
 	 */
-	function set_cipher($cipher)
+	public function set_cipher($cipher)
 	{
 		$this->_mcrypt_cipher = $cipher;
+		return $this;
 	}
 
 	// --------------------------------------------------------------------
@@ -448,13 +432,13 @@
 	/**
 	 * Set the Mcrypt Mode
 	 *
-	 * @access	public
 	 * @param	constant
 	 * @return	string
 	 */
 	function set_mode($mode)
 	{
 		$this->_mcrypt_mode = $mode;
+		return $this;
 	}
 
 	// --------------------------------------------------------------------
@@ -462,10 +446,9 @@
 	/**
 	 * Get Mcrypt cipher Value
 	 *
-	 * @access	private
 	 * @return	string
 	 */
-	function _get_cipher()
+	protected function _get_cipher()
 	{
 		if ($this->_mcrypt_cipher == '')
 		{
@@ -480,10 +463,9 @@
 	/**
 	 * Get Mcrypt Mode Value
 	 *
-	 * @access	private
 	 * @return	string
 	 */
-	function _get_mode()
+	protected function _get_mode()
 	{
 		if ($this->_mcrypt_mode == '')
 		{
@@ -498,11 +480,10 @@
 	/**
 	 * Set the Hash type
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	string
 	 */
-	function set_hash($type = 'sha1')
+	public function set_hash($type = 'sha1')
 	{
 		$this->_hash_type = ($type != 'sha1' AND $type != 'md5') ? 'sha1' : $type;
 	}
@@ -512,45 +493,13 @@
 	/**
 	 * Hash encode a string
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	string
 	 */
-	function hash($str)
+	public function hash($str)
 	{
-		return ($this->_hash_type == 'sha1') ? $this->sha1($str) : md5($str);
+		return ($this->_hash_type == 'sha1') ? sha1($str) : md5($str);
 	}
-
-	// --------------------------------------------------------------------
-
-	/**
-	 * Generate an SHA1 Hash
-	 *
-	 * @access	public
-	 * @param	string
-	 * @return	string
-	 */
-	function sha1($str)
-	{
-		if ( ! function_exists('sha1'))
-		{
-			if ( ! function_exists('mhash'))
-			{
-				require_once(BASEPATH.'libraries/Sha1.php');
-				$SH = new CI_SHA;
-				return $SH->generate($str);
-			}
-			else
-			{
-				return bin2hex(mhash(MHASH_SHA1, $str));
-			}
-		}
-		else
-		{
-			return sha1($str);
-		}
-	}
-
 }
 
 // END CI_Encrypt class
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index 918f690..d83afdd 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -1,4 +1,4 @@
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 /**
  * CodeIgniter
  *
@@ -86,7 +86,7 @@
 	public function set_rules($field, $label = '', $rules = '')
 	{
 		// No reason to set rules if we have no POST data
-		if (count($_POST) == 0)
+		if (count($_POST) === 0)
 		{
 			return $this;
 		}
@@ -113,7 +113,7 @@
 		}
 
 		// No fields? Nothing to do...
-		if ( ! is_string($field) OR  ! is_string($rules) OR $field == '')
+		if ( ! is_string($field) OR ! is_string($rules) OR $field == '')
 		{
 			return $this;
 		}
@@ -121,21 +121,20 @@
 		// If the field label wasn't passed we use the field name
 		$label = ($label == '') ? $field : $label;
 
-		// Is the field name an array?  We test for the existence of a bracket "[" in
-		// the field name to determine this.  If it is an array, we break it apart
+		// Is the field name an array? If it is an array, we break it apart
 		// into its components so that we can fetch the corresponding POST data later
-		if (strpos($field, '[') !== FALSE AND preg_match_all('/\[(.*?)\]/', $field, $matches))
+		if (preg_match_all('/\[(.*?)\]/', $field, $matches))
 		{
 			// Note: Due to a bug in current() that affects some versions
 			// of PHP we can not pass function call directly into it
 			$x = explode('[', $field);
 			$indexes[] = current($x);
 
-			for ($i = 0; $i < count($matches['0']); $i++)
+			for ($i = 0, $c = count($matches[0]); $i < $c; $i++)
 			{
-				if ($matches['1'][$i] != '')
+				if ($matches[1][$i] != '')
 				{
-					$indexes[] = $matches['1'][$i];
+					$indexes[] = $matches[1][$i];
 				}
 			}
 
@@ -293,17 +292,17 @@
 	public function run($group = '')
 	{
 		// Do we even have any data to process?  Mm?
-		if (count($_POST) == 0)
+		if (count($_POST) === 0)
 		{
 			return FALSE;
 		}
 
 		// Does the _field_data array containing the validation rules exist?
 		// If not, we look to see if they were assigned via a config file
-		if (count($this->_field_data) == 0)
+		if (count($this->_field_data) === 0)
 		{
 			// No validation rules?  We're done...
-			if (count($this->_config_rules) == 0)
+			if (count($this->_config_rules) === 0)
 			{
 				return FALSE;
 			}
@@ -321,7 +320,7 @@
 			}
 
 			// We're we able to set the rules correctly?
-			if (count($this->_field_data) == 0)
+			if (count($this->_field_data) === 0)
 			{
 				log_message('debug', "Unable to find validation rules");
 				return FALSE;
@@ -338,7 +337,7 @@
 			// Fetch the data from the corresponding $_POST array and cache it in the _field_data array.
 			// Depending on whether the field name is an array or a string will determine where we get it from.
 
-			if ($row['is_array'] == TRUE)
+			if ($row['is_array'] === TRUE)
 			{
 				$this->_field_data[$field]['postdata'] = $this->_reduce_array($_POST, $row['keys']);
 			}
@@ -364,14 +363,7 @@
 		// Now we need to re-set the POST data with the new, processed data
 		$this->_reset_post_array();
 
-		// No errors, validation passes!
-		if ($total_errors == 0)
-		{
-			return TRUE;
-		}
-
-		// Validation fails
-		return FALSE;
+		return ($total_errors === 0);
 	}
 
 	// --------------------------------------------------------------------
@@ -379,7 +371,7 @@
 	/**
 	 * Traverse a multidimensional $_POST array index until the data is found
 	 *
-	 * @access	private
+	 * @access	protected
 	 * @param	array
 	 * @param	array
 	 * @param	integer
@@ -387,23 +379,9 @@
 	 */
 	protected function _reduce_array($array, $keys, $i = 0)
 	{
-		if (is_array($array))
+		if (is_array($array) && isset($keys[$i]))
 		{
-			if (isset($keys[$i]))
-			{
-				if (isset($array[$keys[$i]]))
-				{
-					$array = $this->_reduce_array($array[$keys[$i]], $keys, ($i+1));
-				}
-				else
-				{
-					return NULL;
-				}
-			}
-			else
-			{
-				return $array;
-			}
+			return isset($array[$keys[$i]]) ? $this->_reduce_array($array[$keys[$i]], $keys, ($i+1)) : NULL;
 		}
 
 		return $array;
@@ -414,7 +392,7 @@
 	/**
 	 * Re-populate the _POST array with our finalized and processed data
 	 *
-	 * @access	private
+	 * @access	protected
 	 * @return	null
 	 */
 	protected function _reset_post_array()
@@ -423,7 +401,7 @@
 		{
 			if ( ! is_null($row['postdata']))
 			{
-				if ($row['is_array'] == FALSE)
+				if ($row['is_array'] === FALSE)
 				{
 					if (isset($_POST[$row['field']]))
 					{
@@ -436,7 +414,7 @@
 					$post_ref =& $_POST;
 
 					// before we assign values, make a reference to the right POST key
-					if (count($row['keys']) == 1)
+					if (count($row['keys']) === 1)
 					{
 						$post_ref =& $post_ref[current($row['keys'])];
 					}
@@ -472,7 +450,7 @@
 	/**
 	 * Executes the Validation routines
 	 *
-	 * @access	private
+	 * @access	protected
 	 * @param	array
 	 * @param	array
 	 * @param	mixed
@@ -514,7 +492,7 @@
 		// --------------------------------------------------------------------
 
 		// Isset Test. Typically this rule will only apply to checkboxes.
-		if (is_null($postdata) AND $callback == FALSE)
+		if (is_null($postdata) AND $callback === FALSE)
 		{
 			if (in_array('isset', $rules, TRUE) OR in_array('required', $rules))
 			{
@@ -605,7 +583,7 @@
 				$result = $this->CI->$rule($postdata, $param);
 
 				// Re-assign the result to the master data array
-				if ($_in_array == TRUE)
+				if ($_in_array === TRUE)
 				{
 					$this->_field_data[$row['field']]['postdata'][$cycles] = (is_bool($result)) ? $postdata : $result;
 				}
@@ -630,7 +608,7 @@
 					{
 						$result = $rule($postdata);
 
-						if ($_in_array == TRUE)
+						if ($_in_array === TRUE)
 						{
 							$this->_field_data[$row['field']]['postdata'][$cycles] = (is_bool($result)) ? $postdata : $result;
 						}
@@ -649,7 +627,7 @@
 
 				$result = $this->$rule($postdata, $param);
 
-				if ($_in_array == TRUE)
+				if ($_in_array === TRUE)
 				{
 					$this->_field_data[$row['field']]['postdata'][$cycles] = (is_bool($result)) ? $postdata : $result;
 				}
@@ -676,7 +654,7 @@
 
 				// Is the parameter we are inserting into the error message the name
 				// of another field?  If so we need to grab its "field label"
-				if (isset($this->_field_data[$param]) AND isset($this->_field_data[$param]['label']))
+				if (isset($this->_field_data[$param], $this->_field_data[$param]['label']))
 				{
 					$param = $this->_translate_fieldname($this->_field_data[$param]['label']);
 				}
@@ -702,7 +680,7 @@
 	/**
 	 * Translate a field name
 	 *
-	 * @access	private
+	 * @access	protected
 	 * @param	string	the field name
 	 * @return	string
 	 */
@@ -710,7 +688,7 @@
 	{
 		// Do we need to translate the field name?
 		// We look for the prefix lang: to determine this
-		if (substr($fieldname, 0, 5) == 'lang:')
+		if (substr($fieldname, 0, 5) === 'lang:')
 		{
 			// Grab the variable
 			$line = substr($fieldname, 5);
@@ -746,7 +724,7 @@
 		}
 
 		// If the data is an array output them one at a time.
-		//     E.g: form_input('name[]', set_value('name[]');
+		//	E.g: form_input('name[]', set_value('name[]');
 		if (is_array($this->_field_data[$field]['postdata']))
 		{
 			return array_shift($this->_field_data[$field]['postdata']);
@@ -858,33 +836,8 @@
 	 */
 	public function set_checkbox($field = '', $value = '', $default = FALSE)
 	{
-		if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata']))
-		{
-			if ($default === TRUE AND count($this->_field_data) === 0)
-			{
-				return ' checked="checked"';
-			}
-			return '';
-		}
-
-		$field = $this->_field_data[$field]['postdata'];
-
-		if (is_array($field))
-		{
-			if ( ! in_array($value, $field))
-			{
-				return '';
-			}
-		}
-		else
-		{
-			if (($field == '' OR $value == '') OR ($field != $value))
-			{
-				return '';
-			}
-		}
-
-		return ' checked="checked"';
+		// Logic is exactly the same as for radio fields
+		return $this->set_radio($field, $value, $default);
 	}
 
 	// --------------------------------------------------------------------
@@ -898,14 +851,7 @@
 	 */
 	public function required($str)
 	{
-		if ( ! is_array($str))
-		{
-			return (trim($str) == '') ? FALSE : TRUE;
-		}
-		else
-		{
-			return ( ! empty($str));
-		}
+		return ( ! is_array($str)) ? (trim($str) !== '') : ( ! empty($str));
 	}
 
 	// --------------------------------------------------------------------
@@ -920,12 +866,7 @@
 	 */
 	public function regex_match($str, $regex)
 	{
-		if ( ! preg_match($regex, $str))
-		{
-			return FALSE;
-		}
-
-		return  TRUE;
+		return (bool) preg_match($regex, $str);
 	}
 
 	// --------------------------------------------------------------------
@@ -947,7 +888,7 @@
 
 		$field = $_POST[$field];
 
-		return ($str !== $field) ? FALSE : TRUE;
+		return ($str === $field);
 	}
 
 	// --------------------------------------------------------------------
@@ -969,7 +910,7 @@
 			return $query->num_rows() === 0;
 		}
 		return FALSE;
-    }
+	}
 
 	// --------------------------------------------------------------------
 
@@ -990,10 +931,10 @@
 
 		if (function_exists('mb_strlen'))
 		{
-			return (mb_strlen($str) < $val) ? FALSE : TRUE;
+			return ! (mb_strlen($str) < $val);
 		}
 
-		return (strlen($str) < $val) ? FALSE : TRUE;
+		return ! (strlen($str) < $val);
 	}
 
 	// --------------------------------------------------------------------
@@ -1015,10 +956,10 @@
 
 		if (function_exists('mb_strlen'))
 		{
-			return (mb_strlen($str) > $val) ? FALSE : TRUE;
+			return ! (mb_strlen($str) > $val);
 		}
 
-		return (strlen($str) > $val) ? FALSE : TRUE;
+		return ! (strlen($str) > $val);
 	}
 
 	// --------------------------------------------------------------------
@@ -1040,10 +981,10 @@
 
 		if (function_exists('mb_strlen'))
 		{
-			return (mb_strlen($str) != $val) ? FALSE : TRUE;
+			return (mb_strlen($str) == $val);
 		}
 
-		return (strlen($str) != $val) ? FALSE : TRUE;
+		return (strlen($str) == $val);
 	}
 
 	// --------------------------------------------------------------------
@@ -1057,7 +998,7 @@
 	 */
 	public function valid_email($str)
 	{
-		return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
+		return (bool) preg_match('/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix', $str);
 	}
 
 	// --------------------------------------------------------------------
@@ -1078,7 +1019,7 @@
 
 		foreach (explode(',', $str) as $email)
 		{
-			if (trim($email) != '' && $this->valid_email(trim($email)) === FALSE)
+			if (trim($email) !== '' && $this->valid_email(trim($email)) === FALSE)
 			{
 				return FALSE;
 			}
@@ -1112,7 +1053,7 @@
 	 */
 	public function alpha($str)
 	{
-		return ( ! preg_match("/^([a-z])+$/i", $str)) ? FALSE : TRUE;
+		return (bool) preg_match('/^[a-z]+$/i', $str);
 	}
 
 	// --------------------------------------------------------------------
@@ -1126,7 +1067,7 @@
 	 */
 	public function alpha_numeric($str)
 	{
-		return ( ! preg_match("/^([a-z0-9])+$/i", $str)) ? FALSE : TRUE;
+		return (bool) preg_match('/^[a-z0-9]+$/i', $str);
 	}
 
 	// --------------------------------------------------------------------
@@ -1140,7 +1081,7 @@
 	 */
 	public function alpha_dash($str)
 	{
-		return ( ! preg_match("/^([-a-z0-9_-])+$/i", $str)) ? FALSE : TRUE;
+		return (bool) preg_match('/^[a-z0-9_-]+$/i', $str);
 	}
 
 	// --------------------------------------------------------------------
@@ -1154,7 +1095,7 @@
 	 */
 	public function numeric($str)
 	{
-		return (bool)preg_match( '/^[\-+]?[0-9]*\.?[0-9]+$/', $str);
+		return (bool) preg_match('/^[\-+]?[0-9]*\.?[0-9]+$/', $str);
 
 	}
 
@@ -1169,7 +1110,7 @@
 	 */
 	public function is_numeric($str)
 	{
-		return ( ! is_numeric($str)) ? FALSE : TRUE;
+		return is_numeric($str);
 	}
 
 	// --------------------------------------------------------------------
@@ -1247,7 +1188,7 @@
 	 */
 	public function is_natural($str)
 	{
-		return (bool) preg_match( '/^[0-9]+$/', $str);
+		return (bool) preg_match('/^[0-9]+$/', $str);
 	}
 
 	// --------------------------------------------------------------------
@@ -1261,17 +1202,7 @@
 	 */
 	public function is_natural_no_zero($str)
 	{
-		if ( ! preg_match( '/^[0-9]+$/', $str))
-		{
-			return FALSE;
-		}
-
-		if ($str == 0)
-		{
-			return FALSE;
-		}
-
-		return TRUE;
+		return ($str != 0 AND preg_match('/^[0-9]+$/', $str));
 	}
 
 	// --------------------------------------------------------------------
@@ -1339,7 +1270,7 @@
 			return '';
 		}
 
-		if (substr($str, 0, 7) != 'http://' && substr($str, 0, 8) != 'https://')
+		if (substr($str, 0, 7) !== 'http://' && substr($str, 0, 8) !== 'https://')
 		{
 			$str = 'http://'.$str;
 		}
diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php
index 15887cb..f872d67 100644
--- a/system/libraries/Javascript.php
+++ b/system/libraries/Javascript.php
@@ -1,13 +1,13 @@
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 /**
  * CodeIgniter
  *
  * An open source application development framework for PHP 5.1.6 or newer
  *
  * NOTICE OF LICENSE
- * 
+ *
  * Licensed under the Open Software License version 3.0
- * 
+ *
  * This source file is subject to the Open Software License (OSL 3.0) that is
  * bundled with this package in the files license.txt / license.rst.  It is
  * also available through the world wide web at this URL:
@@ -38,7 +38,7 @@
  */
 class CI_Javascript {
 
-	var $_javascript_location = 'js';
+	protected $_javascript_location = 'js';
 
 	public function __construct($params = array())
 	{
@@ -64,7 +64,7 @@
 		log_message('debug', "Javascript Class Initialized and loaded.  Driver used: $js_library_driver");
 	}
 
-	// --------------------------------------------------------------------	
+	// --------------------------------------------------------------------
 	// Event Code
 	// --------------------------------------------------------------------
 
@@ -73,12 +73,11 @@
 	 *
 	 * Outputs a javascript library blur event
 	 *
-	 * @access	public
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function blur($element = 'this', $js = '')
+	public function blur($element = 'this', $js = '')
 	{
 		return $this->js->_blur($element, $js);
 	}
@@ -90,12 +89,11 @@
 	 *
 	 * Outputs a javascript library change event
 	 *
-	 * @access	public
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function change($element = 'this', $js = '')
+	public function change($element = 'this', $js = '')
 	{
 		return $this->js->_change($element, $js);
 	}
@@ -107,13 +105,12 @@
 	 *
 	 * Outputs a javascript library click event
 	 *
-	 * @access	public
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @param	boolean	whether or not to return false
 	 * @return	string
 	 */
-	function click($element = 'this', $js = '', $ret_false = TRUE)
+	public function click($element = 'this', $js = '', $ret_false = TRUE)
 	{
 		return $this->js->_click($element, $js, $ret_false);
 	}
@@ -125,12 +122,11 @@
 	 *
 	 * Outputs a javascript library dblclick event
 	 *
-	 * @access	public
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function dblclick($element = 'this', $js = '')
+	public function dblclick($element = 'this', $js = '')
 	{
 		return $this->js->_dblclick($element, $js);
 	}
@@ -142,12 +138,11 @@
 	 *
 	 * Outputs a javascript library error event
 	 *
-	 * @access	public
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function error($element = 'this', $js = '')
+	public function error($element = 'this', $js = '')
 	{
 		return $this->js->_error($element, $js);
 	}
@@ -159,12 +154,11 @@
 	 *
 	 * Outputs a javascript library focus event
 	 *
-	 * @access	public
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function focus($element = 'this', $js = '')
+	public function focus($element = 'this', $js = '')
 	{
 		return $this->js->__add_event($focus, $js);
 	}
@@ -176,13 +170,12 @@
 	 *
 	 * Outputs a javascript library hover event
 	 *
-	 * @access	public
 	 * @param	string	- element
 	 * @param	string	- Javascript code for mouse over
 	 * @param	string	- Javascript code for mouse out
 	 * @return	string
 	 */
-	function hover($element = 'this', $over, $out)
+	public function hover($element = 'this', $over, $out)
 	{
 		return $this->js->__hover($element, $over, $out);
 	}
@@ -194,12 +187,11 @@
 	 *
 	 * Outputs a javascript library keydown event
 	 *
-	 * @access	public
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function keydown($element = 'this', $js = '')
+	public function keydown($element = 'this', $js = '')
 	{
 		return $this->js->_keydown($element, $js);
 	}
@@ -211,12 +203,11 @@
 	 *
 	 * Outputs a javascript library keydown event
 	 *
-	 * @access	public
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function keyup($element = 'this', $js = '')
+	public function keyup($element = 'this', $js = '')
 	{
 		return $this->js->_keyup($element, $js);
 	}
@@ -228,12 +219,11 @@
 	 *
 	 * Outputs a javascript library load event
 	 *
-	 * @access	public
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function load($element = 'this', $js = '')
+	public function load($element = 'this', $js = '')
 	{
 		return $this->js->_load($element, $js);
 	}
@@ -245,12 +235,11 @@
 	 *
 	 * Outputs a javascript library mousedown event
 	 *
-	 * @access	public
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function mousedown($element = 'this', $js = '')
+	public function mousedown($element = 'this', $js = '')
 	{
 		return $this->js->_mousedown($element, $js);
 	}
@@ -262,12 +251,11 @@
 	 *
 	 * Outputs a javascript library mouseout event
 	 *
-	 * @access	public
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function mouseout($element = 'this', $js = '')
+	public function mouseout($element = 'this', $js = '')
 	{
 		return $this->js->_mouseout($element, $js);
 	}
@@ -279,12 +267,11 @@
 	 *
 	 * Outputs a javascript library mouseover event
 	 *
-	 * @access	public
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function mouseover($element = 'this', $js = '')
+	public function mouseover($element = 'this', $js = '')
 	{
 		return $this->js->_mouseover($element, $js);
 	}
@@ -296,12 +283,11 @@
 	 *
 	 * Outputs a javascript library mouseup event
 	 *
-	 * @access	public
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function mouseup($element = 'this', $js = '')
+	public function mouseup($element = 'this', $js = '')
 	{
 		return $this->js->_mouseup($element, $js);
 	}
@@ -313,11 +299,10 @@
 	 *
 	 * Outputs the called javascript to the screen
 	 *
-	 * @access	public
 	 * @param	string	The code to output
 	 * @return	string
 	 */
-	function output($js)
+	public function output($js)
 	{
 		return $this->js->_output($js);
 	}
@@ -329,12 +314,11 @@
 	 *
 	 * Outputs a javascript library mouseup event
 	 *
-	 * @access	public
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function ready($js)
+	public function ready($js)
 	{
 		return $this->js->_document_ready($js);
 	}
@@ -346,12 +330,11 @@
 	 *
 	 * Outputs a javascript library resize event
 	 *
-	 * @access	public
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function resize($element = 'this', $js = '')
+	public function resize($element = 'this', $js = '')
 	{
 		return $this->js->_resize($element, $js);
 	}
@@ -363,12 +346,11 @@
 	 *
 	 * Outputs a javascript library scroll event
 	 *
-	 * @access	public
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function scroll($element = 'this', $js = '')
+	public function scroll($element = 'this', $js = '')
 	{
 		return $this->js->_scroll($element, $js);
 	}
@@ -380,17 +362,16 @@
 	 *
 	 * Outputs a javascript library unload event
 	 *
-	 * @access	public
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function unload($element = 'this', $js = '')
+	public function unload($element = 'this', $js = '')
 	{
 		return $this->js->_unload($element, $js);
 	}
 
-	// --------------------------------------------------------------------	
+	// --------------------------------------------------------------------
 	// Effects
 	// --------------------------------------------------------------------
 
@@ -400,12 +381,11 @@
 	 *
 	 * Outputs a javascript library addClass event
 	 *
-	 * @access	public
 	 * @param	string	- element
 	 * @param	string	- Class to add
 	 * @return	string
 	 */
-	function addClass($element = 'this', $class = '')
+	public function addClass($element = 'this', $class = '')
 	{
 		return $this->js->_addClass($element, $class);
 	}
@@ -417,13 +397,12 @@
 	 *
 	 * Outputs a javascript library animate event
 	 *
-	 * @access	public
 	 * @param	string	- element
 	 * @param	string	- One of 'slow', 'normal', 'fast', or time in milliseconds
 	 * @param	string	- Javascript callback function
 	 * @return	string
 	 */
-	function animate($element = 'this', $params = array(), $speed = '', $extra = '')
+	public function animate($element = 'this', $params = array(), $speed = '', $extra = '')
 	{
 		return $this->js->_animate($element, $params, $speed, $extra);
 	}
@@ -435,13 +414,12 @@
 	 *
 	 * Outputs a javascript library hide event
 	 *
-	 * @access	public
 	 * @param	string	- element
 	 * @param	string	- One of 'slow', 'normal', 'fast', or time in milliseconds
 	 * @param	string	- Javascript callback function
 	 * @return	string
 	 */
-	function fadeIn($element = 'this', $speed = '', $callback = '')
+	public function fadeIn($element = 'this', $speed = '', $callback = '')
 	{
 		return $this->js->_fadeIn($element, $speed, $callback);
 	}
@@ -453,13 +431,12 @@
 	 *
 	 * Outputs a javascript library hide event
 	 *
-	 * @access	public
 	 * @param	string	- element
 	 * @param	string	- One of 'slow', 'normal', 'fast', or time in milliseconds
 	 * @param	string	- Javascript callback function
 	 * @return	string
 	 */
-	function fadeOut($element = 'this', $speed = '', $callback = '')
+	public function fadeOut($element = 'this', $speed = '', $callback = '')
 	{
 		return $this->js->_fadeOut($element, $speed, $callback);
 	}
@@ -470,13 +447,12 @@
 	 *
 	 * Outputs a javascript library slideUp event
 	 *
-	 * @access	public
 	 * @param	string	- element
 	 * @param	string	- One of 'slow', 'normal', 'fast', or time in milliseconds
 	 * @param	string	- Javascript callback function
 	 * @return	string
 	 */
-	function slideUp($element = 'this', $speed = '', $callback = '')
+	public function slideUp($element = 'this', $speed = '', $callback = '')
 	{
 		return $this->js->_slideUp($element, $speed, $callback);
 
@@ -489,12 +465,11 @@
 	 *
 	 * Outputs a javascript library removeClass event
 	 *
-	 * @access	public
 	 * @param	string	- element
 	 * @param	string	- Class to add
 	 * @return	string
 	 */
-	function removeClass($element = 'this', $class = '')
+	public function removeClass($element = 'this', $class = '')
 	{
 		return $this->js->_removeClass($element, $class);
 	}
@@ -506,13 +481,12 @@
 	 *
 	 * Outputs a javascript library slideDown event
 	 *
-	 * @access	public
 	 * @param	string	- element
 	 * @param	string	- One of 'slow', 'normal', 'fast', or time in milliseconds
 	 * @param	string	- Javascript callback function
 	 * @return	string
 	 */
-	function slideDown($element = 'this', $speed = '', $callback = '')
+	public function slideDown($element = 'this', $speed = '', $callback = '')
 	{
 		return $this->js->_slideDown($element, $speed, $callback);
 	}
@@ -524,13 +498,12 @@
 	 *
 	 * Outputs a javascript library slideToggle event
 	 *
-	 * @access	public
 	 * @param	string	- element
 	 * @param	string	- One of 'slow', 'normal', 'fast', or time in milliseconds
 	 * @param	string	- Javascript callback function
 	 * @return	string
 	 */
-	function slideToggle($element = 'this', $speed = '', $callback = '')
+	public function slideToggle($element = 'this', $speed = '', $callback = '')
 	{
 		return $this->js->_slideToggle($element, $speed, $callback);
 
@@ -543,13 +516,12 @@
 	 *
 	 * Outputs a javascript library hide action
 	 *
-	 * @access	public
 	 * @param	string	- element
 	 * @param	string	- One of 'slow', 'normal', 'fast', or time in milliseconds
 	 * @param	string	- Javascript callback function
 	 * @return	string
 	 */
-	function hide($element = 'this', $speed = '', $callback = '')
+	public function hide($element = 'this', $speed = '', $callback = '')
 	{
 		return $this->js->_hide($element, $speed, $callback);
 	}
@@ -561,11 +533,10 @@
 	 *
 	 * Outputs a javascript library toggle event
 	 *
-	 * @access	public
 	 * @param	string	- element
 	 * @return	string
 	 */
-	function toggle($element = 'this')
+	public function toggle($element = 'this')
 	{
 		return $this->js->_toggle($element);
 
@@ -578,11 +549,10 @@
 	 *
 	 * Outputs a javascript library toggle class event
 	 *
-	 * @access	public
 	 * @param	string	- element
 	 * @return	string
 	 */
-	function toggleClass($element = 'this', $class='')
+	public function toggleClass($element = 'this', $class='')
 	{
 		return $this->js->_toggleClass($element, $class);
 	}
@@ -594,13 +564,12 @@
 	 *
 	 * Outputs a javascript library show event
 	 *
-	 * @access	public
 	 * @param	string	- element
 	 * @param	string	- One of 'slow', 'normal', 'fast', or time in milliseconds
 	 * @param	string	- Javascript callback function
 	 * @return	string
 	 */
-	function show($element = 'this', $speed = '', $callback = '')
+	public function show($element = 'this', $speed = '', $callback = '')
 	{
 		return $this->js->_show($element, $speed, $callback);
 	}
@@ -613,11 +582,10 @@
 	 *
 	 * gather together all script needing to be output
 	 *
-	 * @access	public
 	 * @param	string	The element to attach the event to
 	 * @return	string
 	 */
-	function compile($view_var = 'script_foot', $script_tags = TRUE)
+	public function compile($view_var = 'script_foot', $script_tags = TRUE)
 	{
 		$this->js->_compile($view_var, $script_tags);
 	}
@@ -627,10 +595,9 @@
 	 *
 	 * Clears any previous javascript collected for output
 	 *
-	 * @access	public
 	 * @return	void
 	 */
-	function clear_compile()
+	public function clear_compile()
 	{
 		$this->js->_clear_compile();
 	}
@@ -642,11 +609,10 @@
 	 *
 	 * Outputs a <script> tag with the source as an external js file
 	 *
-	 * @access	public
 	 * @param	string	The element to attach the event to
 	 * @return	string
 	 */
-	function external($external_file = '', $relative = FALSE)
+	public function external($external_file = '', $relative = FALSE)
 	{
 		if ($external_file !== '')
 		{
@@ -660,7 +626,7 @@
 			}
 		}
 
-		if ($relative === TRUE OR strncmp($external_file, 'http://', 7) == 0 OR strncmp($external_file, 'https://', 8) == 0)
+		if ($relative === TRUE OR strncmp($external_file, 'http://', 7) === 0 OR strncmp($external_file, 'https://', 8) === 0)
 		{
 			$str = $this->_open_script($external_file);
 		}
@@ -673,8 +639,7 @@
 			$str = $this->_open_script($this->CI->config->slash_item('base_url').$this->_javascript_location.$external_file);
 		}
 
-		$str .= $this->_close_script();
-		return $str;
+		return $str.$this->_close_script();
 	}
 
 	// --------------------------------------------------------------------
@@ -684,20 +649,17 @@
 	 *
 	 * Outputs a <script> tag
 	 *
-	 * @access	public
 	 * @param	string	The element to attach the event to
 	 * @param	boolean	If a CDATA section should be added
 	 * @return	string
 	 */
-	function inline($script, $cdata = TRUE)
+	public function inline($script, $cdata = TRUE)
 	{
-		$str = $this->_open_script();
-		$str .= ($cdata) ? "\n// <![CDATA[\n{$script}\n// ]]>\n" : "\n{$script}\n";
-		$str .= $this->_close_script();
-
-		return $str;
+		return $this->_open_script()
+			. ($cdata ? "\n// <![CDATA[\n{$script}\n// ]]>\n" : "\n{$script}\n")
+			. $this->_close_script();
 	}
-	
+
 	// --------------------------------------------------------------------
 
 	/**
@@ -705,15 +667,13 @@
 	 *
 	 * Outputs an opening <script>
 	 *
-	 * @access	private
 	 * @param	string
 	 * @return	string
 	 */
-	function _open_script($src = '')
+	protected function _open_script($src = '')
 	{
-		$str = '<script type="text/javascript" charset="'.strtolower($this->CI->config->item('charset')).'"';
-		$str .= ($src == '') ? '>' : ' src="'.$src.'">';
-		return $str;
+		return '<script type="text/javascript" charset="'.strtolower($this->CI->config->item('charset')).'"'
+			. ($src == '' ? '>' : ' src="'.$src.'">');
 	}
 
 	// --------------------------------------------------------------------
@@ -723,11 +683,10 @@
 	 *
 	 * Outputs an closing </script>
 	 *
-	 * @access	private
 	 * @param	string
 	 * @return	string
 	 */
-	function _close_script($extra = "\n")
+	protected function _close_script($extra = "\n")
 	{
 		return "</script>$extra";
 	}
@@ -744,13 +703,12 @@
 	 *
 	 * Outputs a javascript library slideDown event
 	 *
-	 * @access	public
 	 * @param	string	- element
 	 * @param	string	- One of 'slow', 'normal', 'fast', or time in milliseconds
 	 * @param	string	- Javascript callback function
 	 * @return	string
 	 */
-	function update($element = 'this', $speed = '', $callback = '')
+	public function update($element = 'this', $speed = '', $callback = '')
 	{
 		return $this->js->_updater($element, $speed, $callback);
 	}
@@ -766,7 +724,7 @@
 	 * @param	bool	match array types (defaults to objects)
 	 * @return	string	a json formatted string
 	 */
-	function generate_json($result = NULL, $match_array_type = FALSE)
+	public function generate_json($result = NULL, $match_array_type = FALSE)
 	{
 		// JSON data can optionally be passed to this function
 		// either as a database result object or an array, or a user supplied array
@@ -827,11 +785,10 @@
 	 *
 	 * Checks for an associative array
 	 *
-	 * @access	public
 	 * @param	type
 	 * @return	type
 	 */
-	function _is_associative_array($arr)
+	protected function _is_associative_array($arr)
 	{
 		foreach (array_keys($arr) as $key => $val)
 		{
@@ -851,11 +808,10 @@
 	 *
 	 * Ensures a standard json value and escapes values
 	 *
-	 * @access	public
 	 * @param	type
 	 * @return	type
 	 */
-	function _prep_args($result, $is_key = FALSE)
+	protected function _prep_args($result, $is_key = FALSE)
 	{
 		if (is_null($result))
 		{
@@ -867,7 +823,7 @@
 		}
 		elseif (is_string($result) OR $is_key)
 		{
-			return '"'.str_replace(array('\\', "\t", "\n", "\r", '"', '/'), array('\\\\', '\\t', '\\n', "\\r", '\"', '\/'), $result).'"';			
+			return '"'.str_replace(array('\\', "\t", "\n", "\r", '"', '/'), array('\\\\', '\\t', '\\n', "\\r", '\"', '\/'), $result).'"';
 		}
 		elseif (is_scalar($result))
 		{
@@ -880,4 +836,4 @@
 // END Javascript Class
 
 /* End of file Javascript.php */
-/* Location: ./system/libraries/Javascript.php */
\ No newline at end of file
+/* Location: ./system/libraries/Javascript.php */
diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php
index 94961b5..eb5161d 100644
--- a/system/libraries/Migration.php
+++ b/system/libraries/Migration.php
@@ -1,4 +1,4 @@
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 /**
  * CodeIgniter
  *
@@ -101,12 +101,9 @@
 		}
 
 		// Do we auto migrate to the latest migration?
-		if ($this->_migration_auto_latest == TRUE)
+		if ($this->_migration_auto_latest === TRUE AND ! $this->latest())
 		{
-			if ( ! $this->latest() )
-			{
-				show_error($this->error_string());
-			}
+			show_error($this->error_string());
 		}
 	}
 
@@ -134,7 +131,6 @@
 			++$stop;
 			$step = 1;
 		}
-
 		else
 		{
 			// Moving Down
@@ -158,11 +154,11 @@
 			}
 
 			// Migration step not found
-			if (count($f) == 0)
+			if (count($f) === 0)
 			{
 				// If trying to migrate up to a version greater than the last
 				// existing one, migrate to the last one.
-				if ($step == 1)
+				if ($step === 1)
 				{
 					break;
 				}
@@ -214,7 +210,7 @@
 
 		log_message('debug', 'Current migration: '.$current_version);
 
-		$version = $i + ($step == 1 ? -1 : 0);
+		$version = $i + ($step === 1 ? -1 : 0);
 
 		// If there is nothing to do so quit
 		if ($migrations === array())
@@ -301,13 +297,11 @@
 	{
 		// Load all *_*.php files in the migrations path
 		$files = glob($this->_migration_path.'*_*.php');
-		$file_count = count($files);
 
-		for ($i = 0; $i < $file_count; $i++)
+		for ($i = 0, $c = count($files); $i < $c; $i++)
 		{
 			// Mark wrongly formatted files as false for later filtering
-			$name = basename($files[$i], '.php');
-			if ( ! preg_match('/^\d{3}_(\w+)$/', $name))
+			if ( ! preg_match('/^\d{3}_(\w+)$/', basename($files[$i], '.php')))
 			{
 				$files[$i] = FALSE;
 			}
@@ -364,4 +358,4 @@
 }
 
 /* End of file Migration.php */
-/* Location: ./system/libraries/Migration.php */
\ No newline at end of file
+/* Location: ./system/libraries/Migration.php */
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index eea953a..008c151 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -1,4 +1,4 @@
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 /**
  * CodeIgniter
  *
@@ -131,7 +131,7 @@
 		$num_pages = ceil($this->total_rows / $this->per_page);
 
 		// Is there only one page? Hm... nothing more to do here then.
-		if ($num_pages == 1)
+		if ($num_pages === 1)
 		{
 			return '';
 		}
@@ -146,25 +146,16 @@
 		{
 			if ($CI->input->get($this->query_string_segment) != $base_page)
 			{
-				$this->cur_page = $CI->input->get($this->query_string_segment);
-
-				// Prep the current page - no funny business!
-				$this->cur_page = (int) $this->cur_page;
+				$this->cur_page = (int) $CI->input->get($this->query_string_segment);
 			}
 		}
-		else
+		elseif ($CI->uri->segment($this->uri_segment) != $base_page)
 		{
-			if ($CI->uri->segment($this->uri_segment) != $base_page)
-			{
-				$this->cur_page = $CI->uri->segment($this->uri_segment);
-
-				// Prep the current page - no funny business!
-				$this->cur_page = (int) $this->cur_page;
-			}
+			$this->cur_page = (int) $CI->uri->segment($this->uri_segment);
 		}
 
-		// Set current page to 1 if using page numbers instead of offset
-		if ($this->use_page_numbers AND $this->cur_page == 0)
+		// Set current page to 1 if it's not valid or if using page numbers instead of offset
+		if ( ! is_numeric($this->cur_page) OR ($this->use_page_numbers AND $this->cur_page == 0))
 		{
 			$this->cur_page = $base_page;
 		}
@@ -176,11 +167,6 @@
 			show_error('Your number of links must be a positive number.');
 		}
 
-		if ( ! is_numeric($this->cur_page))
-		{
-			$this->cur_page = $base_page;
-		}
-
 		// Is the page number beyond the result range?
 		// If so we show the last page
 		if ($this->use_page_numbers)
@@ -310,4 +296,4 @@
 // END Pagination Class
 
 /* End of file Pagination.php */
-/* Location: ./system/libraries/Pagination.php */
\ No newline at end of file
+/* Location: ./system/libraries/Pagination.php */
diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php
index 8a2568d..9cbd69b 100644
--- a/system/libraries/Profiler.php
+++ b/system/libraries/Profiler.php
@@ -1,13 +1,13 @@
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 /**
  * CodeIgniter
  *
  * An open source application development framework for PHP 5.1.6 or newer
  *
  * NOTICE OF LICENSE
- * 
+ *
  * Licensed under the Open Software License version 3.0
- * 
+ *
  * This source file is subject to the Open Software License (OSL 3.0) that is
  * bundled with this package in the files license.txt / license.rst.  It is
  * also available through the world wide web at this URL:
@@ -126,12 +126,10 @@
 		{
 			// We match the "end" marker so that the list ends
 			// up in the order that it was defined
-			if (preg_match("/(.+?)_end/i", $key, $match))
+			if (preg_match('/(.+?)_end/i', $key, $match)
+				AND isset($this->CI->benchmark->marker[$match[1].'_end'], $this->CI->benchmark->marker[$match[1].'_start']))
 			{
-				if (isset($this->CI->benchmark->marker[$match[1].'_end']) AND isset($this->CI->benchmark->marker[$match[1].'_start']))
-				{
-					$profile[$match[1]] = $this->CI->benchmark->elapsed_time($match[1].'_start', $key);
-				}
+				$profile[$match[1]] = $this->CI->benchmark->elapsed_time($match[1].'_start', $key);
 			}
 		}
 
@@ -139,12 +137,11 @@
 		// Note: At some point we should turn this into a template that can
 		// be modified.  We also might want to make this data available to be logged
 
-		$output  = "\n\n";
-		$output .= '<fieldset id="ci_profiler_benchmarks" style="border:1px solid #900;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
-		$output .= "\n";
-		$output .= '<legend style="color:#900;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_benchmarks').'&nbsp;&nbsp;</legend>';
-		$output .= "\n";
-		$output .= "\n\n<table style='width:100%'>\n";
+		$output = "\n\n"
+			. '<fieldset id="ci_profiler_benchmarks" style="border:1px solid #900;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'
+			. "\n"
+			. '<legend style="color:#900;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_benchmarks').'&nbsp;&nbsp;</legend>'
+			. "\n\n\n<table style='width:100%'>\n";
 
 		foreach ($profile as $key => $val)
 		{
@@ -152,10 +149,7 @@
 			$output .= "<tr><td style='padding:5px;width:50%;color:#000;font-weight:bold;background-color:#ddd;'>".$key."&nbsp;&nbsp;</td><td style='padding:5px;width:50%;color:#900;font-weight:normal;background-color:#ddd;'>".$val."</td></tr>\n";
 		}
 
-		$output .= "</table>\n";
-		$output .= "</fieldset>";
-
-		return $output;
+		return $output."</table>\n</fieldset>";
 	}
 
 	// --------------------------------------------------------------------
@@ -178,19 +172,16 @@
 			}
 		}
 
-		if (count($dbs) == 0)
+		if (count($dbs) === 0)
 		{
-			$output  = "\n\n";
-			$output .= '<fieldset id="ci_profiler_queries" style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
-			$output .= "\n";
-			$output .= '<legend style="color:#0000FF;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_queries').'&nbsp;&nbsp;</legend>';
-			$output .= "\n";
-			$output .= "\n\n<table style='border:none; width:100%;'>\n";
-			$output .="<tr><td style='width:100%;color:#0000FF;font-weight:normal;background-color:#eee;padding:5px'>".$this->CI->lang->line('profiler_no_db')."</td></tr>\n";
-			$output .= "</table>\n";
-			$output .= "</fieldset>";
-
-			return $output;
+			return "\n\n"
+				. '<fieldset id="ci_profiler_queries" style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee;">'
+				. "\n"
+				. '<legend style="color:#0000FF;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_queries').'&nbsp;&nbsp;</legend>'
+				. "\n\n\n<table style='border:none; width:100%;'>\n"
+				. '<tr><td style="width:100%;color:#0000FF;font-weight:normal;background-color:#eee;padding:5px;">'
+				. $this->CI->lang->line('profiler_no_db')
+				. "</td></tr>\n</table>\n</fieldset>";
 		}
 
 		// Load the text helper so we can highlight the SQL
@@ -205,8 +196,6 @@
 
 		foreach ($dbs as $db)
 		{
-			$count++;
-
 			$hide_queries = (count($db->queries) > $this->_query_toggle_count) ? ' display:none' : '';
 
 			$show_hide_js = '(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_queries_db_'.$count.'\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_hide').'\'?\''.$this->CI->lang->line('profiler_section_show').'\':\''.$this->CI->lang->line('profiler_section_hide').'\';">'.$this->CI->lang->line('profiler_section_hide').'</span>)';
@@ -216,13 +205,12 @@
 				$show_hide_js = '(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_queries_db_'.$count.'\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)';
 			}
 
-			$output .= '<fieldset style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
-			$output .= "\n";
-			$output .= '<legend style="color:#0000FF;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_database').':&nbsp; '.$db->database.'&nbsp;&nbsp;&nbsp;'.$this->CI->lang->line('profiler_queries').': '.count($db->queries).'&nbsp;&nbsp;'.$show_hide_js.'</legend>';
-			$output .= "\n";
-			$output .= "\n\n<table style='width:100%;{$hide_queries}' id='ci_profiler_queries_db_{$count}'>\n";
+			$output .= '<fieldset style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'
+				. "\n"
+				. '<legend style="color:#0000FF;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_database').':&nbsp; '.$db->database.'&nbsp;&nbsp;&nbsp;'.$this->CI->lang->line('profiler_queries').': '.count($db->queries).'&nbsp;&nbsp;'.$show_hide_js.'</legend>'
+				. "\n\n\n<table style='width:100%;{$hide_queries}' id='ci_profiler_queries_db_{$count}'>\n";
 
-			if (count($db->queries) == 0)
+			if (count($db->queries) === 0)
 			{
 				$output .= "<tr><td style='width:100%;color:#0000FF;font-weight:normal;background-color:#eee;padding:5px;'>".$this->CI->lang->line('profiler_no_queries')."</td></tr>\n";
 			}
@@ -243,8 +231,7 @@
 				}
 			}
 
-			$output .= "</table>\n";
-			$output .= "</fieldset>";
+			$output .= "</table>\n</fieldset>";
 
 		}
 
@@ -261,13 +248,13 @@
 	 */
 	protected function _compile_get()
 	{
-		$output  = "\n\n";
-		$output .= '<fieldset id="ci_profiler_get" style="border:1px solid #cd6e00;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
-		$output .= "\n";
-		$output .= '<legend style="color:#cd6e00;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_get_data').'&nbsp;&nbsp;</legend>';
-		$output .= "\n";
+		$output  = "\n\n"
+			. '<fieldset id="ci_profiler_get" style="border:1px solid #cd6e00;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'
+			. "\n"
+			. '<legend style="color:#cd6e00;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_get_data').'&nbsp;&nbsp;</legend>'
+			. "\n";
 
-		if (count($_GET) == 0)
+		if (count($_GET) === 0)
 		{
 			$output .= "<div style='color:#cd6e00;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_get')."</div>";
 		}
@@ -282,23 +269,15 @@
 					$key = "'".$key."'";
 				}
 
-				$output .= "<tr><td style='width:50%;color:#000;background-color:#ddd;padding:5px'>&#36;_GET[".$key."]&nbsp;&nbsp; </td><td style='width:50%;padding:5px;color:#cd6e00;font-weight:normal;background-color:#ddd;'>";
-				if (is_array($val))
-				{
-					$output .= "<pre>" . htmlspecialchars(stripslashes(print_r($val, true))) . "</pre>";
-				}
-				else
-				{
-					$output .= htmlspecialchars(stripslashes($val));
-				}
-				$output .= "</td></tr>\n";
+				$output .= "<tr><td style='width:50%;color:#000;background-color:#ddd;padding:5px'>&#36;_GET[".$key."]&nbsp;&nbsp; </td><td style='width:50%;padding:5px;color:#cd6e00;font-weight:normal;background-color:#ddd;'>"
+					. (is_array($val) ? "<pre>" . htmlspecialchars(stripslashes(print_r($val, true))) . "</pre>" : htmlspecialchars(stripslashes($val)))
+					. "</td></tr>\n";
 			}
 
 			$output .= "</table>\n";
 		}
-		$output .= "</fieldset>";
 
-		return $output;
+		return $output.'</fieldset>';
 	}
 
 	// --------------------------------------------------------------------
@@ -310,11 +289,11 @@
 	 */
 	protected function _compile_post()
 	{
-		$output  = "\n\n";
-		$output .= '<fieldset id="ci_profiler_post" style="border:1px solid #009900;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
-		$output .= "\n";
-		$output .= '<legend style="color:#009900;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_post_data').'&nbsp;&nbsp;</legend>';
-		$output .= "\n";
+		$output = "\n\n"
+			. '<fieldset id="ci_profiler_post" style="border:1px solid #009900;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'
+			. "\n"
+			. '<legend style="color:#009900;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_post_data').'&nbsp;&nbsp;</legend>'
+			. "\n";
 
 		if (count($_POST) == 0)
 		{
@@ -345,9 +324,8 @@
 
 			$output .= "</table>\n";
 		}
-		$output .= "</fieldset>";
 
-		return $output;
+		return $output.'</fieldset>';
 	}
 
 	// --------------------------------------------------------------------
@@ -359,24 +337,13 @@
 	 */
 	protected function _compile_uri_string()
 	{
-		$output  = "\n\n";
-		$output .= '<fieldset id="ci_profiler_uri_string" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
-		$output .= "\n";
-		$output .= '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_uri_string').'&nbsp;&nbsp;</legend>';
-		$output .= "\n";
-
-		if ($this->CI->uri->uri_string == '')
-		{
-			$output .= "<div style='color:#000;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_uri')."</div>";
-		}
-		else
-		{
-			$output .= "<div style='color:#000;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->uri->uri_string."</div>";
-		}
-
-		$output .= "</fieldset>";
-
-		return $output;
+		return "\n\n"
+			. '<fieldset id="ci_profiler_uri_string" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'
+			. "\n"
+			. '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_uri_string').'&nbsp;&nbsp;</legend>'
+			. "\n<div style='color:#000;font-weight:normal;padding:4px 0 4px 0'>"
+			. ($this->CI->uri->uri_string == '' ? $this->CI->lang->line('profiler_no_uri') : $this->CI->uri->uri_string)
+			. '</div></fieldset>';
 	}
 
 	// --------------------------------------------------------------------
@@ -388,17 +355,12 @@
 	 */
 	protected function _compile_controller_info()
 	{
-		$output  = "\n\n";
-		$output .= '<fieldset id="ci_profiler_controller_info" style="border:1px solid #995300;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
-		$output .= "\n";
-		$output .= '<legend style="color:#995300;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_controller_info').'&nbsp;&nbsp;</legend>';
-		$output .= "\n";
-
-		$output .= "<div style='color:#995300;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->router->fetch_class()."/".$this->CI->router->fetch_method()."</div>";
-
-		$output .= "</fieldset>";
-
-		return $output;
+		return "\n\n"
+			. '<fieldset id="ci_profiler_controller_info" style="border:1px solid #995300;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'
+			. "\n"
+			. '<legend style="color:#995300;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_controller_info').'&nbsp;&nbsp;</legend>'
+			. "\n<div style='color:#995300;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->router->fetch_class().'/'.$this->CI->router->fetch_method()
+			. '</div></fieldset>';
 	}
 
 	// --------------------------------------------------------------------
@@ -412,24 +374,13 @@
 	 */
 	protected function _compile_memory_usage()
 	{
-		$output  = "\n\n";
-		$output .= '<fieldset id="ci_profiler_memory_usage" style="border:1px solid #5a0099;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
-		$output .= "\n";
-		$output .= '<legend style="color:#5a0099;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_memory_usage').'&nbsp;&nbsp;</legend>';
-		$output .= "\n";
-
-		if (function_exists('memory_get_usage') && ($usage = memory_get_usage()) != '')
-		{
-			$output .= "<div style='color:#5a0099;font-weight:normal;padding:4px 0 4px 0'>".number_format($usage).' bytes</div>';
-		}
-		else
-		{
-			$output .= "<div style='color:#5a0099;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_memory')."</div>";
-		}
-
-		$output .= "</fieldset>";
-
-		return $output;
+		return "\n\n"
+			. '<fieldset id="ci_profiler_memory_usage" style="border:1px solid #5a0099;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'
+			. "\n"
+			. '<legend style="color:#5a0099;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_memory_usage').'&nbsp;&nbsp;</legend>'
+			. "\n<div style='color:#5a0099;font-weight:normal;padding:4px 0 4px 0'>"
+			. ((function_exists('memory_get_usage') && ($usage = memory_get_usage()) != '') ? number_format($usage).' bytes' : $this->CI->lang->line('profiler_no_memory'))
+			. '</div></fieldset>';
 	}
 
 	// --------------------------------------------------------------------
@@ -443,13 +394,11 @@
 	 */
 	protected function _compile_http_headers()
 	{
-		$output  = "\n\n";
-		$output .= '<fieldset id="ci_profiler_http_headers" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
-		$output .= "\n";
-		$output .= '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_headers').'&nbsp;&nbsp;(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_httpheaders_table\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)</legend>';
-		$output .= "\n";
-
-		$output .= "\n\n<table style='width:100%;display:none' id='ci_profiler_httpheaders_table'>\n";
+		$output = "\n\n"
+			. '<fieldset id="ci_profiler_http_headers" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'
+			. "\n"
+			. '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_headers').'&nbsp;&nbsp;(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_httpheaders_table\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)</legend>'
+			. "\n\n\n<table style='width:100%;display:none' id='ci_profiler_httpheaders_table'>\n";
 
 		foreach (array('HTTP_ACCEPT', 'HTTP_USER_AGENT', 'HTTP_CONNECTION', 'SERVER_PORT', 'SERVER_NAME', 'REMOTE_ADDR', 'SERVER_SOFTWARE', 'HTTP_ACCEPT_LANGUAGE', 'SCRIPT_NAME', 'REQUEST_METHOD',' HTTP_HOST', 'REMOTE_HOST', 'CONTENT_TYPE', 'SERVER_PROTOCOL', 'QUERY_STRING', 'HTTP_ACCEPT_ENCODING', 'HTTP_X_FORWARDED_FOR') as $header)
 		{
@@ -457,10 +406,7 @@
 			$output .= "<tr><td style='vertical-align: top;width:50%;padding:5px;color:#900;background-color:#ddd;'>".$header."&nbsp;&nbsp;</td><td style='width:50%;padding:5px;color:#000;background-color:#ddd;'>".$val."</td></tr>\n";
 		}
 
-		$output .= "</table>\n";
-		$output .= "</fieldset>";
-
-		return $output;
+		return $output."</table>\n</fieldset>";
 	}
 
 	// --------------------------------------------------------------------
@@ -474,13 +420,11 @@
 	 */
 	protected function _compile_config()
 	{
-		$output  = "\n\n";
-		$output .= '<fieldset id="ci_profiler_config" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
-		$output .= "\n";
-		$output .= '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_config').'&nbsp;&nbsp;(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_config_table\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)</legend>';
-		$output .= "\n";
-
-		$output .= "\n\n<table style='width:100%; display:none' id='ci_profiler_config_table'>\n";
+		$output = "\n\n"
+			. '<fieldset id="ci_profiler_config" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'
+			. "\n"
+			. '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_config').'&nbsp;&nbsp;(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_config_table\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)</legend>'
+			. "\n\n\n<table style='width:100%; display:none' id='ci_profiler_config_table'>\n";
 
 		foreach ($this->CI->config->config as $config=>$val)
 		{
@@ -492,10 +436,7 @@
 			$output .= "<tr><td style='padding:5px; vertical-align: top;color:#900;background-color:#ddd;'>".$config."&nbsp;&nbsp;</td><td style='padding:5px; color:#000;background-color:#ddd;'>".htmlspecialchars($val)."</td></tr>\n";
 		}
 
-		$output .= "</table>\n";
-		$output .= "</fieldset>";
-
-		return $output;
+		return $output."</table>\n</fieldset>";
 	}
 
 	// --------------------------------------------------------------------
@@ -512,9 +453,9 @@
 			return;
 		}
 
-		$output = '<fieldset id="ci_profiler_csession" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
-		$output .= '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_session_data').'&nbsp;&nbsp;(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_session_data\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)</legend>';
-		$output .= "<table style='width:100%;display:none' id='ci_profiler_session_data'>";
+		$output = '<fieldset id="ci_profiler_csession" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'
+			. '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_session_data').'&nbsp;&nbsp;(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_session_data\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)</legend>'
+			. "<table style='width:100%;display:none' id='ci_profiler_session_data'>";
 
 		foreach ($this->CI->session->all_userdata() as $key => $val)
 		{
@@ -526,9 +467,7 @@
 			$output .= "<tr><td style='padding:5px; vertical-align: top;color:#900;background-color:#ddd;'>".$key."&nbsp;&nbsp;</td><td style='padding:5px; color:#000;background-color:#ddd;'>".htmlspecialchars($val)."</td></tr>\n";
 		}
 
-		$output .= '</table>';
-		$output .= "</fieldset>";
-		return $output;
+		return $output."</table>\n</fieldset>";
 	}
 
 	// --------------------------------------------------------------------
@@ -553,14 +492,12 @@
 			}
 		}
 
-		if ($fields_displayed == 0)
+		if ($fields_displayed === 0)
 		{
 			$output .= '<p style="border:1px solid #5a0099;padding:10px;margin:20px 0;background-color:#eee">'.$this->CI->lang->line('profiler_no_profiles').'</p>';
 		}
 
-		$output .= '</div>';
-
-		return $output;
+		return $output.'</div>';
 	}
 }
 
diff --git a/system/libraries/Sha1.php b/system/libraries/Sha1.php
deleted file mode 100644
index 477b92b..0000000
--- a/system/libraries/Sha1.php
+++ /dev/null
@@ -1,263 +0,0 @@
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * CodeIgniter
- *
- * An open source application development framework for PHP 5.1.6 or newer
- *
- * NOTICE OF LICENSE
- * 
- * Licensed under the Open Software License version 3.0
- * 
- * This source file is subject to the Open Software License (OSL 3.0) that is
- * bundled with this package in the files license.txt / license.rst.  It is
- * also available through the world wide web at this URL:
- * http://opensource.org/licenses/OSL-3.0
- * If you did not receive a copy of the license and are unable to obtain it
- * through the world wide web, please send an email to
- * licensing@ellislab.com so we can send you a copy immediately.
- *
- * @package		CodeIgniter
- * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
- * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
- * @link		http://codeigniter.com
- * @since		Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * SHA1 Encoding Class
- *
- * Purpose: Provides 160 bit hashing using The Secure Hash Algorithm
- * developed at the National Institute of Standards and Technology. The 40
- * character SHA1 message hash is computationally infeasible to crack.
- *
- * This class is a fallback for servers that are not running PHP greater than
- * 4.3, or do not have the MHASH library.
- *
- * This class is based on two scripts:
- *
- * Marcus Campbell's PHP implementation (GNU license)
- * http://www.tecknik.net/sha-1/
- *
- * ...which is based on Paul Johnston's JavaScript version
- * (BSD license). http://pajhome.org.uk/
- *
- * I encapsulated the functions and wrote one additional method to fix
- * a hex conversion bug. - Rick Ellis
- *
- * @package		CodeIgniter
- * @subpackage	Libraries
- * @category	Encryption
- * @author		EllisLab Dev Team
- * @link		http://codeigniter.com/user_guide/libraries/encryption.html
- */
-class CI_SHA1 {
-
-	public function __construct()
-	{
-		log_message('debug', "SHA1 Class Initialized");
-	}
-
-	/**
-	 * Generate the Hash
-	 *
-	 * @access	public
-	 * @param	string
-	 * @return	string
-	 */
-	function generate($str)
-	{
-		$n = ((strlen($str) + 8) >> 6) + 1;
-
-		for ($i = 0; $i < $n * 16; $i++)
-		{
-			$x[$i] = 0;
-		}
-
-		for ($i = 0; $i < strlen($str); $i++)
-		{
-			$x[$i >> 2] |= ord(substr($str, $i, 1)) << (24 - ($i % 4) * 8);
-		}
-
-		$x[$i >> 2] |= 0x80 << (24 - ($i % 4) * 8);
-
-		$x[$n * 16 - 1] = strlen($str) * 8;
-
-		$a =  1732584193;
-		$b = -271733879;
-		$c = -1732584194;
-		$d =  271733878;
-		$e = -1009589776;
-
-		for ($i = 0; $i < count($x); $i += 16)
-		{
-			$olda = $a;
-			$oldb = $b;
-			$oldc = $c;
-			$oldd = $d;
-			$olde = $e;
-
-			for ($j = 0; $j < 80; $j++)
-			{
-				if ($j < 16)
-				{
-					$w[$j] = $x[$i + $j];
-				}
-				else
-				{
-					$w[$j] = $this->_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1);
-				}
-
-				$t = $this->_safe_add($this->_safe_add($this->_rol($a, 5), $this->_ft($j, $b, $c, $d)), $this->_safe_add($this->_safe_add($e, $w[$j]), $this->_kt($j)));
-
-				$e = $d;
-				$d = $c;
-				$c = $this->_rol($b, 30);
-				$b = $a;
-				$a = $t;
-			}
-
-			$a = $this->_safe_add($a, $olda);
-			$b = $this->_safe_add($b, $oldb);
-			$c = $this->_safe_add($c, $oldc);
-			$d = $this->_safe_add($d, $oldd);
-			$e = $this->_safe_add($e, $olde);
-		}
-
-		return $this->_hex($a).$this->_hex($b).$this->_hex($c).$this->_hex($d).$this->_hex($e);
-	}
-
-	// --------------------------------------------------------------------
-
-	/**
-	 * Convert a decimal to hex
-	 *
-	 * @access	private
-	 * @param	string
-	 * @return	string
-	 */
-	function _hex($str)
-	{
-		$str = dechex($str);
-
-		if (strlen($str) == 7)
-		{
-			$str = '0'.$str;
-		}
-
-		return $str;
-	}
-
-	// --------------------------------------------------------------------
-
-	/**
-	 *  Return result based on iteration
-	 *
-	 * @access	private
-	 * @return	string
-	 */
-	function _ft($t, $b, $c, $d)
-	{
-		if ($t < 20)
-			return ($b & $c) | ((~$b) & $d);
-		if ($t < 40)
-			return $b ^ $c ^ $d;
-		if ($t < 60)
-			return ($b & $c) | ($b & $d) | ($c & $d);
-
-		return $b ^ $c ^ $d;
-	}
-
-	// --------------------------------------------------------------------
-
-	/**
-	 * Determine the additive constant
-	 *
-	 * @access	private
-	 * @return	string
-	 */
-	function _kt($t)
-	{
-		if ($t < 20)
-		{
-			return 1518500249;
-		}
-		else if ($t < 40)
-		{
-			return 1859775393;
-		}
-		else if ($t < 60)
-		{
-			return -1894007588;
-		}
-		else
-		{
-			return -899497514;
-		}
-	}
-
-	// --------------------------------------------------------------------
-
-	/**
-	 * Add integers, wrapping at 2^32
-	 *
-	 * @access	private
-	 * @return	string
-	 */
-	function _safe_add($x, $y)
-	{
-		$lsw = ($x & 0xFFFF) + ($y & 0xFFFF);
-		$msw = ($x >> 16) + ($y >> 16) + ($lsw >> 16);
-
-		return ($msw << 16) | ($lsw & 0xFFFF);
-	}
-
-	// --------------------------------------------------------------------
-
-	/**
-	 * Bitwise rotate a 32-bit number
-	 *
-	 * @access	private
-	 * @return	integer
-	 */
-	function _rol($num, $cnt)
-	{
-		return ($num << $cnt) | $this->_zero_fill($num, 32 - $cnt);
-	}
-
-	// --------------------------------------------------------------------
-
-	/**
-	 * Pad string with zero
-	 *
-	 * @access	private
-	 * @return	string
-	 */
-	function _zero_fill($a, $b)
-	{
-		$bin = decbin($a);
-
-		if (strlen($bin) < $b)
-		{
-			$bin = 0;
-		}
-		else
-		{
-			$bin = substr($bin, 0, strlen($bin) - $b);
-		}
-
-		for ($i=0; $i < $b; $i++)
-		{
-			$bin = "0".$bin;
-		}
-
-		return bindec($bin);
-	}
-}
-// END CI_SHA
-
-/* End of file Sha1.php */
-/* Location: ./system/libraries/Sha1.php */
diff --git a/system/libraries/Table.php b/system/libraries/Table.php
index 8d0e11a..1851bf3 100644
--- a/system/libraries/Table.php
+++ b/system/libraries/Table.php
@@ -1,13 +1,13 @@
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 /**
  * CodeIgniter
  *
  * An open source application development framework for PHP 5.1.6 or newer
  *
  * NOTICE OF LICENSE
- * 
+ *
  * Licensed under the Open Software License version 3.0
- * 
+ *
  * This source file is subject to the Open Software License (OSL 3.0) that is
  * bundled with this package in the files license.txt / license.rst.  It is
  * also available through the world wide web at this URL:
@@ -40,14 +40,14 @@
  */
 class CI_Table {
 
-	var $rows				= array();
-	var $heading			= array();
-	var $auto_heading		= TRUE;
-	var $caption			= NULL;
-	var $template			= NULL;
-	var $newline			= "\n";
-	var $empty_cells		= "";
-	var	$function			= FALSE;
+	public $rows			= array();
+	public $heading			= array();
+	public $auto_heading		= TRUE;
+	public $caption			= NULL;
+	public $template		= NULL;
+	public $newline			= "\n";
+	public $empty_cells		= '';
+	public $function		= FALSE;
 
 	public function __construct()
 	{
@@ -59,11 +59,10 @@
 	/**
 	 * Set the template
 	 *
-	 * @access	public
 	 * @param	array
 	 * @return	void
 	 */
-	function set_template($template)
+	public function set_template($template)
 	{
 		if ( ! is_array($template))
 		{
@@ -80,11 +79,10 @@
 	 *
 	 * Can be passed as an array or discreet params
 	 *
-	 * @access	public
 	 * @param	mixed
 	 * @return	void
 	 */
-	function set_heading()
+	public function set_heading()
 	{
 		$args = func_get_args();
 		$this->heading = $this->_prep_args($args);
@@ -98,14 +96,13 @@
 	 * columns.  This allows a single array with many elements to  be
 	 * displayed in a table that has a fixed column count.
 	 *
-	 * @access	public
 	 * @param	array
 	 * @param	int
 	 * @return	void
 	 */
-	function make_columns($array = array(), $col_limit = 0)
+	public function make_columns($array = array(), $col_limit = 0)
 	{
-		if ( ! is_array($array) OR count($array) == 0)
+		if ( ! is_array($array) OR count($array) === 0)
 		{
 			return FALSE;
 		}
@@ -120,7 +117,7 @@
 		}
 
 		$new = array();
-		while (count($array) > 0)
+		do
 		{
 			$temp = array_splice($array, 0, $col_limit);
 
@@ -134,6 +131,7 @@
 
 			$new[] = $temp;
 		}
+		while (count($array) > 0);
 
 		return $new;
 	}
@@ -145,11 +143,10 @@
 	 *
 	 * Can be passed as an array or discreet params
 	 *
-	 * @access	public
 	 * @param	mixed
 	 * @return	void
 	 */
-	function set_empty($value)
+	public function set_empty($value)
 	{
 		$this->empty_cells = $value;
 	}
@@ -161,11 +158,10 @@
 	 *
 	 * Can be passed as an array or discreet params
 	 *
-	 * @access	public
 	 * @param	mixed
 	 * @return	void
 	 */
-	function add_row()
+	public function add_row()
 	{
 		$args = func_get_args();
 		$this->rows[] = $this->_prep_args($args);
@@ -178,16 +174,15 @@
 	 *
 	 * Ensures a standard associative array format for all cell data
 	 *
-	 * @access	public
 	 * @param	type
 	 * @return	type
 	 */
-	function _prep_args($args)
+	protected function _prep_args($args)
 	{
 		// If there is no $args[0], skip this and treat as an associative array
 		// This can happen if there is only a single key, for example this is passed to table->generate
 		// array(array('foo'=>'bar'))
-		if (isset($args[0]) AND (count($args) == 1 && is_array($args[0])))
+		if (isset($args[0]) AND (count($args) === 1 && is_array($args[0])))
 		{
 			// args sent as indexed array
 			if ( ! isset($args[0]['data']))
@@ -224,11 +219,10 @@
 	/**
 	 * Add a table caption
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	void
 	 */
-	function set_caption($caption)
+	public function set_caption($caption)
 	{
 		$this->caption = $caption;
 	}
@@ -238,11 +232,10 @@
 	/**
 	 * Generate the table
 	 *
-	 * @access	public
 	 * @param	mixed
 	 * @return	string
 	 */
-	function generate($table_data = NULL)
+	public function generate($table_data = NULL)
 	{
 		// The table data can optionally be passed to this function
 		// either as a database result object or an array
@@ -254,13 +247,13 @@
 			}
 			elseif (is_array($table_data))
 			{
-				$set_heading = (count($this->heading) == 0 AND $this->auto_heading == FALSE) ? FALSE : TRUE;
+				$set_heading = (count($this->heading) === 0 AND $this->auto_heading == FALSE) ? FALSE : TRUE;
 				$this->_set_from_array($table_data, $set_heading);
 			}
 		}
 
 		// Is there anything to display?  No?  Smite them!
-		if (count($this->heading) == 0 AND count($this->rows) == 0)
+		if (count($this->heading) === 0 AND count($this->rows) === 0)
 		{
 			return 'Undefined table data';
 		}
@@ -273,24 +266,18 @@
 
 		// Build the table!
 
-		$out = $this->template['table_open'];
-		$out .= $this->newline;
+		$out = $this->template['table_open'].$this->newline;
 
 		// Add any caption here
 		if ($this->caption)
 		{
-			$out .= $this->newline;
-			$out .= '<caption>' . $this->caption . '</caption>';
-			$out .= $this->newline;
+			$out .= $this->newline.'<caption>'.$this->caption.'</caption>'.$this->newline;
 		}
 
 		// Is there a table heading to display?
 		if (count($this->heading) > 0)
 		{
-			$out .= $this->template['thead_open'];
-			$out .= $this->newline;
-			$out .= $this->template['heading_row_start'];
-			$out .= $this->newline;
+			$out .= $this->template['thead_open'].$this->newline.$this->template['heading_row_start'].$this->newline;
 
 			foreach ($this->heading as $heading)
 			{
@@ -304,22 +291,16 @@
 					}
 				}
 
-				$out .= $temp;
-				$out .= isset($heading['data']) ? $heading['data'] : '';
-				$out .= $this->template['heading_cell_end'];
+				$out .= $temp.(isset($heading['data']) ? $heading['data'] : '').$this->template['heading_cell_end'];
 			}
 
-			$out .= $this->template['heading_row_end'];
-			$out .= $this->newline;
-			$out .= $this->template['thead_close'];
-			$out .= $this->newline;
+			$out .= $this->template['heading_row_end'].$this->newline.$this->template['thead_close'].$this->newline;
 		}
 
 		// Build the table rows
 		if (count($this->rows) > 0)
 		{
-			$out .= $this->template['tbody_open'];
-			$out .= $this->newline;
+			$out .= $this->template['tbody_open'].$this->newline;
 
 			$i = 1;
 			foreach ($this->rows as $row)
@@ -332,8 +313,7 @@
 				// We use modulus to alternate the row colors
 				$name = (fmod($i++, 2)) ? '' : 'alt_';
 
-				$out .= $this->template['row_'.$name.'start'];
-				$out .= $this->newline;
+				$out .= $this->template['row_'.$name.'start'].$this->newline;
 
 				foreach ($row as $cell)
 				{
@@ -341,7 +321,7 @@
 
 					foreach ($cell as $key => $val)
 					{
-						if ($key != 'data')
+						if ($key !== 'data')
 						{
 							$temp = str_replace('<td', "<td $key='$val'", $temp);
 						}
@@ -369,12 +349,10 @@
 					$out .= $this->template['cell_'.$name.'end'];
 				}
 
-				$out .= $this->template['row_'.$name.'end'];
-				$out .= $this->newline;
+				$out .= $this->template['row_'.$name.'end'].$this->newline;
 			}
 
-			$out .= $this->template['tbody_close'];
-			$out .= $this->newline;
+			$out .= $this->template['tbody_close'].$this->newline;
 		}
 
 		$out .= $this->template['table_close'];
@@ -390,10 +368,9 @@
 	/**
 	 * Clears the table arrays.  Useful if multiple tables are being generated
 	 *
-	 * @access	public
 	 * @return	void
 	 */
-	function clear()
+	public function clear()
 	{
 		$this->rows				= array();
 		$this->heading			= array();
@@ -405,11 +382,10 @@
 	/**
 	 * Set table data from a database result object
 	 *
-	 * @access	public
 	 * @param	object
 	 * @return	void
 	 */
-	function _set_from_object($query)
+	protected function _set_from_object($query)
 	{
 		if ( ! is_object($query))
 		{
@@ -417,7 +393,7 @@
 		}
 
 		// First generate the headings from the table column names
-		if (count($this->heading) == 0)
+		if (count($this->heading) === 0)
 		{
 			if ( ! method_exists($query, 'list_fields'))
 			{
@@ -443,13 +419,12 @@
 	/**
 	 * Set table data from an array
 	 *
-	 * @access	public
 	 * @param	array
 	 * @return	void
 	 */
-	function _set_from_array($data, $set_heading = TRUE)
+	protected function _set_from_array($data, $set_heading = TRUE)
 	{
-		if ( ! is_array($data) OR count($data) == 0)
+		if ( ! is_array($data) OR count($data) === 0)
 		{
 			return FALSE;
 		}
@@ -458,7 +433,7 @@
 		foreach ($data as $row)
 		{
 			// If a heading hasn't already been set we'll use the first row of the array as the heading
-			if ($i == 0 AND count($data) > 1 AND count($this->heading) == 0 AND $set_heading == TRUE)
+			if ($i++ === 0 AND count($data) > 1 AND count($this->heading) === 0 AND $set_heading == TRUE)
 			{
 				$this->heading = $this->_prep_args($row);
 			}
@@ -466,8 +441,6 @@
 			{
 				$this->rows[] = $this->_prep_args($row);
 			}
-
-			$i++;
 		}
 	}
 
@@ -476,10 +449,9 @@
 	/**
 	 * Compile Template
 	 *
-	 * @access	private
 	 * @return	void
 	 */
-	function _compile_template()
+	protected function _compile_template()
 	{
 		if ($this->template == NULL)
 		{
@@ -502,10 +474,9 @@
 	/**
 	 * Default Template
 	 *
-	 * @access	private
 	 * @return	void
 	 */
-	function _default_template()
+	protected function _default_template()
 	{
 		return  array (
 						'table_open'			=> '<table border="0" cellpadding="4" cellspacing="0">',
@@ -538,6 +509,5 @@
 
 }
 
-
 /* End of file Table.php */
 /* Location: ./system/libraries/Table.php */
diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php
index 1e59283..b5e6850 100644
--- a/system/libraries/Trackback.php
+++ b/system/libraries/Trackback.php
@@ -1,4 +1,4 @@
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 /**
  * CodeIgniter
  *
@@ -47,11 +47,6 @@
 	public $response		= '';
 	public $error_msg		= array();
 
-	/**
-	 * Constructor
-	 *
-	 * @access	public
-	 */
 	public function __construct()
 	{
 		log_message('debug', "Trackback Class Initialized");
@@ -62,7 +57,6 @@
 	/**
 	 * Send Trackback
 	 *
-	 * @access	public
 	 * @param	array
 	 * @return	bool
 	 */
@@ -96,20 +90,9 @@
 			}
 
 			// Convert High ASCII Characters
-			if ($this->convert_ascii == TRUE)
+			if ($this->convert_ascii == TRUE && in_array($item, array('excerpt', 'title', 'blog_name')))
 			{
-				if ($item == 'excerpt')
-				{
-					$$item = $this->convert_ascii($$item);
-				}
-				elseif ($item == 'title')
-				{
-					$$item = $this->convert_ascii($$item);
-				}
-				elseif ($item == 'blog_name')
-				{
-					$$item = $this->convert_ascii($$item);
-				}
+				$$item = $this->convert_ascii($$item);
 			}
 		}
 
@@ -144,7 +127,6 @@
 	 * If the data is valid it is set to the $this->data array
 	 * so that it can be inserted into a database.
 	 *
-	 * @access	public
 	 * @return	bool
 	 */
 	public function receive()
@@ -186,7 +168,6 @@
 	 * sends the "incomplete information" error, as that's
 	 * the most common one.
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	void
 	 */
@@ -204,7 +185,6 @@
 	 * This should be called when a trackback has been
 	 * successfully received and inserted.
 	 *
-	 * @access	public
 	 * @return	void
 	 */
 	public function send_success()
@@ -218,7 +198,6 @@
 	/**
 	 * Fetch a particular item
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	string
 	 */
@@ -235,7 +214,6 @@
 	 * Opens a socket connection and passes the data to
 	 * the server.  Returns TRUE on success, FALSE on failure
 	 *
-	 * @access	public
 	 * @param	string
 	 * @param	string
 	 * @return	bool
@@ -280,15 +258,9 @@
 		@fclose($fp);
 
 
-		if (stristr($this->response, '<error>0</error>') === FALSE)
+		if (stripos($this->response, '<error>0</error>') === FALSE)
 		{
-			$message = 'An unknown error was encountered';
-
-			if (preg_match("/<message>(.*?)<\/message>/is", $this->response, $match))
-			{
-				$message = trim($match['1']);
-			}
-
+			$message = (preg_match('/<message>(.*?)<\/message>/is', $this->response, $match)) ? trim($match[1]) : 'An unknown error was encountered';
 			$this->set_error($message);
 			return FALSE;
 		}
@@ -305,7 +277,6 @@
 	 * It takes a string of URLs (separated by comma or
 	 * space) and puts each URL into an array
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	string
 	 */
@@ -318,7 +289,7 @@
 		$urls = str_replace(",,", ",", $urls);
 
 		// Remove any comma that might be at the end
-		if (substr($urls, -1) == ",")
+		if (substr($urls, -1) === ',')
 		{
 			$urls = substr($urls, 0, -1);
 		}
@@ -341,7 +312,6 @@
 	 *
 	 * Simply adds "http://" if missing
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	string
 	 */
@@ -349,9 +319,9 @@
 	{
 		$url = trim($url);
 
-		if (substr($url, 0, 4) != "http")
+		if (strpos($url, 'http') !== 0)
 		{
-			$url = "http://".$url;
+			$url = 'http://'.$url;
 		}
 	}
 
@@ -360,7 +330,6 @@
 	/**
 	 * Find the Trackback URL's ID
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	string
 	 */
@@ -409,7 +378,6 @@
 	/**
 	 * Convert Reserved XML characters to Entities
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	string
 	 */
@@ -417,15 +385,13 @@
 	{
 		$temp = '__TEMP_AMPERSANDS__';
 
-		$str = preg_replace("/&#(\d+);/", "$temp\\1;", $str);
-		$str = preg_replace("/&(\w+);/",  "$temp\\1;", $str);
+		$str = preg_replace(array('/&#(\d+);/', '/&(\w+);/'), "$temp\\1;", $str);
 
 		$str = str_replace(array("&","<",">","\"", "'", "-"),
 							array("&amp;", "&lt;", "&gt;", "&quot;", "&#39;", "&#45;"),
 							$str);
 
-		$str = preg_replace("/$temp(\d+);/","&#\\1;",$str);
-		$str = preg_replace("/$temp(\w+);/","&\\1;", $str);
+		$str = preg_replace(array("/$temp(\d+);/", "/$temp(\w+);/"), array('&#\\1;', '&\\1;'), $str);
 
 		return $str;
 	}
@@ -437,7 +403,6 @@
 	 *
 	 * Limits the string based on the character count. Will preserve complete words.
 	 *
-	 * @access	public
 	 * @param	string
 	 * @param	integer
 	 * @param	string
@@ -457,13 +422,13 @@
 			return $str;
 		}
 
-		$out = "";
+		$out = '';
 		foreach (explode(' ', trim($str)) as $val)
 		{
 			$out .= $val.' ';
 			if (strlen($out) >= $n)
 			{
-				return trim($out).$end_char;
+				return rtrim($out).$end_char;
 			}
 		}
 	}
@@ -476,7 +441,6 @@
 	 * Converts Hight ascii text and MS Word special chars
 	 * to character entities
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	string
 	 */
@@ -496,16 +460,16 @@
 			}
 			else
 			{
-				if (count($temp) == 0)
+				if (count($temp) === 0)
 				{
 					$count = ($ordinal < 224) ? 2 : 3;
 				}
 
 				$temp[] = $ordinal;
 
-				if (count($temp) == $count)
+				if (count($temp) === $count)
 				{
-					$number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64);
+					$number = ($count == 3) ? (($temp[0] % 16) * 4096) + (($temp[1] % 64) * 64) + ($temp[2] % 64) : (($temp[0] % 32) * 64) + ($temp[1] % 64);
 
 					$out .= '&#'.$number.';';
 					$count = 1;
@@ -522,7 +486,6 @@
 	/**
 	 * Set error message
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	void
 	 */
@@ -537,7 +500,6 @@
 	/**
 	 * Show error messages
 	 *
-	 * @access	public
 	 * @param	string
 	 * @param	string
 	 * @return	string
diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php
index af6ca2b..651ba7b 100644
--- a/system/libraries/Typography.php
+++ b/system/libraries/Typography.php
@@ -1,13 +1,13 @@
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 /**
  * CodeIgniter
  *
  * An open source application development framework for PHP 5.1.6 or newer
  *
  * NOTICE OF LICENSE
- * 
+ *
  * Licensed under the Open Software License version 3.0
- * 
+ *
  * This source file is subject to the Open Software License (OSL 3.0) that is
  * bundled with this package in the files license.txt / license.rst.  It is
  * also available through the world wide web at this URL:
@@ -31,7 +31,7 @@
  * Typography Class
  *
  *
- * @access		private
+ * @access		protected
  * @category	Helpers
  * @author		EllisLab Dev Team
  * @link		http://codeigniter.com/user_guide/libraries/typography.html
@@ -39,22 +39,22 @@
 class CI_Typography {
 
 	// Block level elements that should not be wrapped inside <p> tags
-	var $block_elements = 'address|blockquote|div|dl|fieldset|form|h\d|hr|noscript|object|ol|p|pre|script|table|ul';
+	public $block_elements = 'address|blockquote|div|dl|fieldset|form|h\d|hr|noscript|object|ol|p|pre|script|table|ul';
 
 	// Elements that should not have <p> and <br /> tags within them.
-	var $skip_elements	= 'p|pre|ol|ul|dl|object|table|h\d';
+	public $skip_elements	= 'p|pre|ol|ul|dl|object|table|h\d';
 
 	// Tags we want the parser to completely ignore when splitting the string.
-	var $inline_elements = 'a|abbr|acronym|b|bdo|big|br|button|cite|code|del|dfn|em|i|img|ins|input|label|map|kbd|q|samp|select|small|span|strong|sub|sup|textarea|tt|var';
+	public $inline_elements = 'a|abbr|acronym|b|bdo|big|br|button|cite|code|del|dfn|em|i|img|ins|input|label|map|kbd|q|samp|select|small|span|strong|sub|sup|textarea|tt|var';
 
 	// array of block level elements that require inner content to be within another block level element
-	var $inner_block_required = array('blockquote');
+	public $inner_block_required = array('blockquote');
 
 	// the last block element parsed
-	var $last_block_element = '';
+	public $last_block_element = '';
 
 	// whether or not to protect quotes within { curly braces }
-	var $protect_braced_quotes = FALSE;
+	public $protect_braced_quotes = FALSE;
 
 	/**
 	 * Auto Typography
@@ -72,7 +72,7 @@
 	 * @param	bool	whether to reduce more then two consecutive newlines to two
 	 * @return	string
 	 */
-	function auto_typography($str, $reduce_linebreaks = FALSE)
+	public function auto_typography($str, $reduce_linebreaks = FALSE)
 	{
 		if ($str == '')
 		{
@@ -127,35 +127,32 @@
 		// adversely affected if they are split out so we'll convert the opening bracket < temporarily to: {@TAG}
 		$str = preg_replace("#<(/*)(".$this->inline_elements.")([ >])#i", "{@TAG}\\1\\2\\3", $str);
 
-		// Split the string at every tag.  This expression creates an array with this prototype:
-		//
-		//	[array]
-		//	{
-		//		[0] = <opening tag>
-		//		[1] = Content...
-		//		[2] = <closing tag>
-		//		Etc...
-		//	}
+		/* Split the string at every tag. This expression creates an array with this prototype:
+		 *
+		 *	[array]
+		 *	{
+		 *		[0] = <opening tag>
+		 *		[1] = Content...
+		 *		[2] = <closing tag>
+		 *		Etc...
+		 *	}
+		 */
 		$chunks = preg_split('/(<(?:[^<>]+(?:"[^"]*"|\'[^\']*\')?)+>)/', $str, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
 
 		// Build our finalized string.  We cycle through the array, skipping tags, and processing the contained text
 		$str = '';
 		$process = TRUE;
 		$paragraph = FALSE;
-		$current_chunk = 0;
-		$total_chunks = count($chunks);
 
-		foreach ($chunks as $chunk)
+		for ($i = 1, $c = count($chunks); $i <= $c; $i++)
 		{
-			$current_chunk++;
-
 			// Are we dealing with a tag? If so, we'll skip the processing for this cycle.
 			// Well also set the "process" flag which allows us to skip <pre> tags and a few other things.
-			if (preg_match("#<(/*)(".$this->block_elements.").*?>#", $chunk, $match))
+			if (preg_match("#<(/*)(".$this->block_elements.").*?>#", $chunks[$i], $match))
 			{
 				if (preg_match("#".$this->skip_elements."#", $match[2]))
 				{
-					$process =  ($match[1] == '/') ? TRUE : FALSE;
+					$process = ($match[1] === '/');
 				}
 
 				if ($match[1] == '')
@@ -163,24 +160,24 @@
 					$this->last_block_element = $match[2];
 				}
 
-				$str .= $chunk;
+				$str .= $chunks[$i];
 				continue;
 			}
 
-			if ($process == FALSE)
+			if ($process === FALSE)
 			{
-				$str .= $chunk;
+				$str .= $chunks[$i];
 				continue;
 			}
 
 			//  Force a newline to make sure end tags get processed by _format_newlines()
-			if ($current_chunk == $total_chunks)
+			if ($i === $c)
 			{
-				$chunk .= "\n";
+				$chunks[$i] .= "\n";
 			}
 
 			//  Convert Newlines into <p> and <br /> tags
-			$str .= $this->_format_newlines($chunk);
+			$str .= $this->_format_newlines($chunks[$i]);
 		}
 
 		// No opening block level tag?  Add it if needed.
@@ -265,7 +262,7 @@
 	 * @param	string
 	 * @return	string
 	 */
-	function format_characters($str)
+	public function format_characters($str)
 	{
 		static $table;
 
@@ -325,18 +322,13 @@
 	 *
 	 * Converts newline characters into either <p> tags or <br />
 	 *
-	 * @access	public
+	 * @access	protected
 	 * @param	string
 	 * @return	string
 	 */
-	function _format_newlines($str)
+	protected function _format_newlines($str)
 	{
-		if ($str == '')
-		{
-			return $str;
-		}
-
-		if (strpos($str, "\n") === FALSE  && ! in_array($this->last_block_element, $this->inner_block_required))
+		if ($str == '' OR (strpos($str, "\n") === FALSE AND ! in_array($this->last_block_element, $this->inner_block_required)))
 		{
 			return $str;
 		}
@@ -373,11 +365,11 @@
 	 * and we don't want double dashes converted to emdash entities, so they are marked with {@DD}
 	 * likewise double spaces are converted to {@NBS} to prevent entity conversion
 	 *
-	 * @access	public
+	 * @access	protected
 	 * @param	array
 	 * @return	string
 	 */
-	function _protect_characters($match)
+	protected function _protect_characters($match)
 	{
 		return str_replace(array("'",'"','--','  '), array('{@SQ}', '{@DQ}', '{@DD}', '{@NBS}'), $match[0]);
 	}
@@ -391,25 +383,16 @@
 	 * @param	string
 	 * @return	string
 	 */
-	function nl2br_except_pre($str)
+	public function nl2br_except_pre($str)
 	{
-		$ex = explode("pre>",$str);
-		$ct = count($ex);
-
-		$newstr = "";
-		for ($i = 0; $i < $ct; $i++)
+		$newstr = '';
+		for ($ex = explode('pre>', $str), $ct = count($ex), $i = 0; $i < $ct; $i++)
 		{
-			if (($i % 2) == 0)
+			$newstr .= (($i % 2) === 0) ? nl2br($ex[$i]) : $ex[$i];
+			if ($ct - 1 !== $i)
 			{
-				$newstr .= nl2br($ex[$i]);
+				$newstr .= 'pre>';
 			}
-			else
-			{
-				$newstr .= $ex[$i];
-			}
-
-			if ($ct - 1 != $i)
-				$newstr .= "pre>";
 		}
 
 		return $newstr;
diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php
index 7afe40b..fd3880d 100644
--- a/system/libraries/Unit_test.php
+++ b/system/libraries/Unit_test.php
@@ -1,13 +1,13 @@
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 /**
  * CodeIgniter
  *
  * An open source application development framework for PHP 5.1.6 or newer
  *
  * NOTICE OF LICENSE
- * 
+ *
  * Licensed under the Open Software License version 3.0
- * 
+ *
  * This source file is subject to the Open Software License (OSL 3.0) that is
  * bundled with this package in the files license.txt / license.rst.  It is
  * also available through the world wide web at this URL:
@@ -40,12 +40,12 @@
  */
 class CI_Unit_test {
 
-	var $active					= TRUE;
-	var $results				= array();
-	var $strict					= FALSE;
-	var $_template				= NULL;
-	var $_template_rows			= NULL;
-	var $_test_items_visible	= array();
+	public $active					= TRUE;
+	public $results				= array();
+	public $strict					= FALSE;
+	protected $_template				= NULL;
+	protected $_template_rows			= NULL;
+	protected $_test_items_visible	= array();
 
 	public function __construct()
 	{
@@ -70,11 +70,10 @@
 	 *
 	 * Runs the supplied tests
 	 *
-	 * @access	public
 	 * @param	array
 	 * @return	void
 	 */
-	function set_test_items($items = array())
+	public function set_test_items($items = array())
 	{
 		if ( ! empty($items) AND is_array($items))
 		{
@@ -89,13 +88,12 @@
 	 *
 	 * Runs the supplied tests
 	 *
-	 * @access	public
 	 * @param	mixed
 	 * @param	mixed
 	 * @param	string
 	 * @return	string
 	 */
-	function run($test, $expected = TRUE, $test_name = 'undefined', $notes = '')
+	public function run($test, $expected = TRUE, $test_name = 'undefined', $notes = '')
 	{
 		if ($this->active == FALSE)
 		{
@@ -110,11 +108,7 @@
 		}
 		else
 		{
-			if ($this->strict == TRUE)
-				$result = ($test === $expected) ? TRUE : FALSE;
-			else
-				$result = ($test == $expected) ? TRUE : FALSE;
-
+			$result = ($this->strict == TRUE) ? ($test === $expected) : ($test == $expected);
 			$extype = gettype($expected);
 		}
 
@@ -142,12 +136,11 @@
 	 *
 	 * Displays a table with the test data
 	 *
-	 * @access	public
 	 * @return	string
 	 */
-	function report($result = array())
+	public function report($result = array())
 	{
-		if (count($result) == 0)
+		if (count($result) === 0)
 		{
 			$result = $this->result();
 		}
@@ -176,10 +169,7 @@
 					}
 				}
 
-				$temp = $this->_template_rows;
-				$temp = str_replace('{item}', $key, $temp);
-				$temp = str_replace('{result}', $val, $temp);
-				$table .= $temp;
+				$table .= str_replace(array('{item}', '{result}'), array($key, $val), $this->_template_rows);
 			}
 
 			$r .= str_replace('{rows}', $table, $this->_template);
@@ -195,13 +185,12 @@
 	 *
 	 * Causes the evaluation to use === rather than ==
 	 *
-	 * @access	public
 	 * @param	bool
 	 * @return	null
 	 */
-	function use_strict($state = TRUE)
+	public function use_strict($state = TRUE)
 	{
-		$this->strict = ($state == FALSE) ? FALSE : TRUE;
+		$this->strict = (bool) $state;
 	}
 
 	// --------------------------------------------------------------------
@@ -211,13 +200,12 @@
 	 *
 	 * Enables/disables unit testing
 	 *
-	 * @access	public
 	 * @param	bool
 	 * @return	null
 	 */
-	function active($state = TRUE)
+	public function active($state = TRUE)
 	{
-		$this->active = ($state == FALSE) ? FALSE : TRUE;
+		$this->active = (bool) $state;
 	}
 
 	// --------------------------------------------------------------------
@@ -227,15 +215,14 @@
 	 *
 	 * Returns the raw result data
 	 *
-	 * @access	public
 	 * @return	array
 	 */
-	function result($results = array())
+	public function result($results = array())
 	{
 		$CI =& get_instance();
 		$CI->load->language('unit_test');
 
-		if (count($results) == 0)
+		if (count($results) === 0)
 		{
 			$results = $this->results;
 		}
@@ -285,11 +272,10 @@
 	 *
 	 * This lets us set the template to be used to display results
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	void
 	 */
-	function set_template($template)
+	public function set_template($template)
 	{
 		$this->_template = $template;
 	}
@@ -301,19 +287,17 @@
 	 *
 	 * This lets us show file names and line numbers
 	 *
-	 * @access	private
 	 * @return	array
 	 */
-	function _backtrace()
+	protected function _backtrace()
 	{
 		if (function_exists('debug_backtrace'))
 		{
 			$back = debug_backtrace();
-
-			$file = ( ! isset($back['1']['file'])) ? '' : $back['1']['file'];
-			$line = ( ! isset($back['1']['line'])) ? '' : $back['1']['line'];
-
-			return array('file' => $file, 'line' => $line);
+			return array(
+					'file' => (isset($back[1]['file']) ? $back[1]['file'] : ''),
+					'line' => (isset($back[1]['line']) ? $back[1]['line'] : '')
+				);
 		}
 		return array('file' => 'Unknown', 'line' => 'Unknown');
 	}
@@ -323,19 +307,14 @@
 	/**
 	 * Get Default Template
 	 *
-	 * @access	private
 	 * @return	string
 	 */
-	function _default_template()
+	protected function _default_template()
 	{
-		$this->_template = "\n".'<table style="width:100%; font-size:small; margin:10px 0; border-collapse:collapse; border:1px solid #CCC;">';
-		$this->_template .= '{rows}';
-		$this->_template .= "\n".'</table>';
+		$this->_template = "\n".'<table style="width:100%; font-size:small; margin:10px 0; border-collapse:collapse; border:1px solid #CCC;">{rows}'."\n".'</table>';
 
-		$this->_template_rows = "\n\t".'<tr>';
-		$this->_template_rows .= "\n\t\t".'<th style="text-align: left; border-bottom:1px solid #CCC;">{item}</th>';
-		$this->_template_rows .= "\n\t\t".'<td style="border-bottom:1px solid #CCC;">{result}</td>';
-		$this->_template_rows .= "\n\t".'</tr>';
+		$this->_template_rows = "\n\t<tr>\n\t\t".'<th style="text-align: left; border-bottom:1px solid #CCC;">{item}</th>'
+					. "\n\t\t".'<td style="border-bottom:1px solid #CCC;">{result}</td>'."\n\t</tr>";
 	}
 
 	// --------------------------------------------------------------------
@@ -345,30 +324,23 @@
 	 *
 	 * Harvests the data within the template {pseudo-variables}
 	 *
-	 * @access	private
 	 * @return	void
 	 */
-	function _parse_template()
+	protected function _parse_template()
 	{
 		if ( ! is_null($this->_template_rows))
 		{
 			return;
 		}
 
-		if (is_null($this->_template))
+		if (is_null($this->_template) OR ! preg_match("/\{rows\}(.*?)\{\/rows\}/si", $this->_template, $match))
 		{
 			$this->_default_template();
 			return;
 		}
 
-		if ( ! preg_match("/\{rows\}(.*?)\{\/rows\}/si", $this->_template, $match))
-		{
-			$this->_default_template();
-			return;
-		}
-
-		$this->_template_rows = $match['1'];
-		$this->_template = str_replace($match['0'], '{rows}', $this->_template);
+		$this->_template_rows = $match[1];
+		$this->_template = str_replace($match[0], '{rows}', $this->_template);
 	}
 
 }
@@ -377,8 +349,6 @@
 /**
  * Helper functions to test boolean true/false
  *
- *
- * @access	private
  * @return	bool
  */
 function is_true($test)
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 826bcce..5108afa 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -952,17 +952,12 @@
 	{
 		global $mimes;
 
-		if (count($this->mimes) == 0)
+		if (count($this->mimes) === 0)
 		{
-			if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
-			{
-				include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php');
-			}
-			elseif (is_file(APPPATH.'config/mimes.php'))
-			{
-				include(APPPATH.'config//mimes.php');
-			}
-			else
+			load_environ_config('mimes');
+
+			// Return FALSE if we still have no mimes after trying to load them up.
+			if (count($this->mimes) === 0)
 			{
 				return FALSE;
 			}
diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php
index a007ace..5288525 100644
--- a/system/libraries/User_agent.php
+++ b/system/libraries/User_agent.php
@@ -1,13 +1,13 @@
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 /**
  * CodeIgniter
  *
  * An open source application development framework for PHP 5.1.6 or newer
  *
  * NOTICE OF LICENSE
- * 
+ *
  * Licensed under the Open Software License version 3.0
- * 
+ *
  * This source file is subject to the Open Software License (OSL 3.0) that is
  * bundled with this package in the files license.txt / license.rst.  It is
  * also available through the world wide web at this URL:
@@ -40,32 +40,31 @@
  */
 class CI_User_agent {
 
-	var $agent		= NULL;
+	public $agent		= NULL;
 
-	var $is_browser	= FALSE;
-	var $is_robot	= FALSE;
-	var $is_mobile	= FALSE;
+	public $is_browser	= FALSE;
+	public $is_robot	= FALSE;
+	public $is_mobile	= FALSE;
 
-	var $languages	= array();
-	var $charsets	= array();
+	public $languages	= array();
+	public $charsets	= array();
 
-	var $platforms	= array();
-	var $browsers	= array();
-	var $mobiles	= array();
-	var $robots		= array();
+	public $platforms	= array();
+	public $browsers	= array();
+	public $mobiles		= array();
+	public $robots		= array();
 
-	var $platform	= '';
-	var $browser	= '';
-	var $version	= '';
-	var $mobile		= '';
-	var $robot		= '';
+	public $platform	= '';
+	public $browser		= '';
+	public $version		= '';
+	public $mobile		= '';
+	public $robot		= '';
 
 	/**
 	 * Constructor
 	 *
 	 * Sets the User Agent and runs the compilation routine
 	 *
-	 * @access	public
 	 * @return	void
 	 */
 	public function __construct()
@@ -91,20 +90,14 @@
 	/**
 	 * Compile the User Agent Data
 	 *
-	 * @access	private
 	 * @return	bool
 	 */
-	private function _load_agent_file()
+	protected function _load_agent_file()
 	{
-		if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php'))
-		{
-			include(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php');
-		}
-		elseif (is_file(APPPATH.'config/user_agents.php'))
-		{
-			include(APPPATH.'config/user_agents.php');
-		}
-		else
+		load_environ_config('user_agents');
+
+		// Return FALSE if we still have no mimes after trying to load them up.
+		if (count($this->mimes) === 0)
 		{
 			return FALSE;
 		}
@@ -147,10 +140,9 @@
 	/**
 	 * Compile the User Agent Data
 	 *
-	 * @access	private
 	 * @return	bool
 	 */
-	private function _compile_data()
+	protected function _compile_data()
 	{
 		$this->_set_platform();
 
@@ -168,10 +160,9 @@
 	/**
 	 * Set the Platform
 	 *
-	 * @access	private
 	 * @return	mixed
 	 */
-	private function _set_platform()
+	protected function _set_platform()
 	{
 		if (is_array($this->platforms) AND count($this->platforms) > 0)
 		{
@@ -192,10 +183,9 @@
 	/**
 	 * Set the Browser
 	 *
-	 * @access	private
 	 * @return	bool
 	 */
-	private function _set_browser()
+	protected function _set_browser()
 	{
 		if (is_array($this->browsers) AND count($this->browsers) > 0)
 		{
@@ -219,10 +209,9 @@
 	/**
 	 * Set the Robot
 	 *
-	 * @access	private
 	 * @return	bool
 	 */
-	private function _set_robot()
+	protected function _set_robot()
 	{
 		if (is_array($this->robots) AND count($this->robots) > 0)
 		{
@@ -244,10 +233,9 @@
 	/**
 	 * Set the Mobile Device
 	 *
-	 * @access	private
 	 * @return	bool
 	 */
-	private function _set_mobile()
+	protected function _set_mobile()
 	{
 		if (is_array($this->mobiles) AND count($this->mobiles) > 0)
 		{
@@ -269,19 +257,16 @@
 	/**
 	 * Set the accepted languages
 	 *
-	 * @access	private
 	 * @return	void
 	 */
-	private function _set_languages()
+	protected function _set_languages()
 	{
-		if ((count($this->languages) == 0) AND isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) AND $_SERVER['HTTP_ACCEPT_LANGUAGE'] != '')
+		if ((count($this->languages) === 0) AND isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) AND $_SERVER['HTTP_ACCEPT_LANGUAGE'] != '')
 		{
-			$languages = preg_replace('/(;q=[0-9\.]+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_LANGUAGE'])));
-
-			$this->languages = explode(',', $languages);
+			$this->languages = explode(',', preg_replace('/(;q=[0-9\.]+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_LANGUAGE']))));
 		}
 
-		if (count($this->languages) == 0)
+		if (count($this->languages) === 0)
 		{
 			$this->languages = array('Undefined');
 		}
@@ -292,19 +277,16 @@
 	/**
 	 * Set the accepted character sets
 	 *
-	 * @access	private
 	 * @return	void
 	 */
-	private function _set_charsets()
+	protected function _set_charsets()
 	{
-		if ((count($this->charsets) == 0) AND isset($_SERVER['HTTP_ACCEPT_CHARSET']) AND $_SERVER['HTTP_ACCEPT_CHARSET'] != '')
+		if ((count($this->charsets) === 0) AND isset($_SERVER['HTTP_ACCEPT_CHARSET']) AND $_SERVER['HTTP_ACCEPT_CHARSET'] != '')
 		{
-			$charsets = preg_replace('/(;q=.+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_CHARSET'])));
-
-			$this->charsets = explode(',', $charsets);
+			$this->charsets = explode(',', preg_replace('/(;q=.+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_CHARSET']))));
 		}
 
-		if (count($this->charsets) == 0)
+		if (count($this->charsets) === 0)
 		{
 			$this->charsets = array('Undefined');
 		}
@@ -315,7 +297,6 @@
 	/**
 	 * Is Browser
 	 *
-	 * @access	public
 	 * @return	bool
 	 */
 	public function is_browser($key = NULL)
@@ -340,7 +321,6 @@
 	/**
 	 * Is Robot
 	 *
-	 * @access	public
 	 * @return	bool
 	 */
 	public function is_robot($key = NULL)
@@ -365,7 +345,6 @@
 	/**
 	 * Is Mobile
 	 *
-	 * @access	public
 	 * @return	bool
 	 */
 	public function is_mobile($key = NULL)
@@ -390,16 +369,11 @@
 	/**
 	 * Is this a referral from another site?
 	 *
-	 * @access	public
 	 * @return	bool
 	 */
 	public function is_referral()
 	{
-		if ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '')
-		{
-			return FALSE;
-		}
-		return TRUE;
+		return ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '') ? FALSE : TRUE;
 	}
 
 	// --------------------------------------------------------------------
@@ -407,7 +381,6 @@
 	/**
 	 * Agent String
 	 *
-	 * @access	public
 	 * @return	string
 	 */
 	public function agent_string()
@@ -420,7 +393,6 @@
 	/**
 	 * Get Platform
 	 *
-	 * @access	public
 	 * @return	string
 	 */
 	public function platform()
@@ -433,7 +405,6 @@
 	/**
 	 * Get Browser Name
 	 *
-	 * @access	public
 	 * @return	string
 	 */
 	public function browser()
@@ -446,7 +417,6 @@
 	/**
 	 * Get the Browser Version
 	 *
-	 * @access	public
 	 * @return	string
 	 */
 	public function version()
@@ -459,7 +429,6 @@
 	/**
 	 * Get The Robot Name
 	 *
-	 * @access	public
 	 * @return	string
 	 */
 	public function robot()
@@ -471,7 +440,6 @@
 	/**
 	 * Get the Mobile Device
 	 *
-	 * @access	public
 	 * @return	string
 	 */
 	public function mobile()
@@ -484,7 +452,6 @@
 	/**
 	 * Get the referrer
 	 *
-	 * @access	public
 	 * @return	bool
 	 */
 	public function referrer()
@@ -497,12 +464,11 @@
 	/**
 	 * Get the accepted languages
 	 *
-	 * @access	public
 	 * @return	array
 	 */
 	public function languages()
 	{
-		if (count($this->languages) == 0)
+		if (count($this->languages) === 0)
 		{
 			$this->_set_languages();
 		}
@@ -515,12 +481,11 @@
 	/**
 	 * Get the accepted Character Sets
 	 *
-	 * @access	public
 	 * @return	array
 	 */
 	public function charsets()
 	{
-		if (count($this->charsets) == 0)
+		if (count($this->charsets) === 0)
 		{
 			$this->_set_charsets();
 		}
@@ -533,7 +498,6 @@
 	/**
 	 * Test for a particular language
 	 *
-	 * @access	public
 	 * @return	bool
 	 */
 	public function accept_lang($lang = 'en')
@@ -546,7 +510,6 @@
 	/**
 	 * Test for a particular character set
 	 *
-	 * @access	public
 	 * @return	bool
 	 */
 	public function accept_charset($charset = 'utf-8')
@@ -556,6 +519,5 @@
 
 }
 
-
 /* End of file User_agent.php */
 /* Location: ./system/libraries/User_agent.php */
diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php
index 587b750..893e518 100644
--- a/system/libraries/Xmlrpcs.php
+++ b/system/libraries/Xmlrpcs.php
@@ -1,13 +1,13 @@
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 /**
  * CodeIgniter
  *
  * An open source application development framework for PHP 5.1.6 or newer
  *
  * NOTICE OF LICENSE
- * 
+ *
  * Licensed under the Open Software License version 3.0
- * 
+ *
  * This source file is subject to the Open Software License (OSL 3.0) that is
  * bundled with this package in the files license.txt / license.rst.  It is
  * also available through the world wide web at this URL:
@@ -48,12 +48,11 @@
  */
 class CI_Xmlrpcs extends CI_Xmlrpc
 {
-	var $methods		= array();	//array of methods mapped to function names and signatures
-	var $debug_msg		= '';		// Debug Message
-	var $system_methods = array();	// XML RPC Server methods
-	var $controller_obj;
-
-	var $object			= FALSE;
+	public $methods		= array();	//array of methods mapped to function names and signatures
+	public $debug_msg	= '';		// Debug Message
+	public $system_methods	= array();	// XML RPC Server methods
+	public $controller_obj;
+	public $object		= FALSE;
 
 	/**
 	 * Constructor
@@ -80,7 +79,7 @@
 	 * @param	mixed
 	 * @return	void
 	 */
-	function initialize($config=array())
+	public function initialize($config = array())
 	{
 		if (isset($config['functions']) && is_array($config['functions']))
 		{
@@ -111,26 +110,26 @@
 	 * @access	public
 	 * @return	void
 	 */
-	function set_system_methods()
+	public function set_system_methods()
 	{
 		$this->methods = array(
 					'system.listMethods'	 => array(
-													'function' => 'this.listMethods',
-													'signature' => array(array($this->xmlrpcArray, $this->xmlrpcString), array($this->xmlrpcArray)),
-													'docstring' => 'Returns an array of available methods on this server'),
-					'system.methodHelp'		 => array(
-													'function' => 'this.methodHelp',
-													'signature' => array(array($this->xmlrpcString, $this->xmlrpcString)),
-													'docstring' => 'Returns a documentation string for the specified method'),
+										'function' => 'this.listMethods',
+										'signature' => array(array($this->xmlrpcArray, $this->xmlrpcString), array($this->xmlrpcArray)),
+										'docstring' => 'Returns an array of available methods on this server'),
+					'system.methodHelp'	 => array(
+										'function' => 'this.methodHelp',
+										'signature' => array(array($this->xmlrpcString, $this->xmlrpcString)),
+										'docstring' => 'Returns a documentation string for the specified method'),
 					'system.methodSignature' => array(
-													'function' => 'this.methodSignature',
-													'signature' => array(array($this->xmlrpcArray, $this->xmlrpcString)),
-													'docstring' => 'Returns an array describing the return type and required parameters of a method'),
-					'system.multicall'		 => array(
-												'function' => 'this.multicall',
-												'signature' => array(array($this->xmlrpcArray, $this->xmlrpcArray)),
-												'docstring' => 'Combine multiple RPC calls in one request. See http://www.xmlrpc.com/discuss/msgReader$1208 for details')
-					);
+										'function' => 'this.methodSignature',
+										'signature' => array(array($this->xmlrpcArray, $this->xmlrpcString)),
+										'docstring' => 'Returns an array describing the return type and required parameters of a method'),
+					'system.multicall'	 => array(
+										'function' => 'this.multicall',
+										'signature' => array(array($this->xmlrpcArray, $this->xmlrpcArray)),
+										'docstring' => 'Combine multiple RPC calls in one request. See http://www.xmlrpc.com/discuss/msgReader$1208 for details')
+				);
 	}
 
 	// --------------------------------------------------------------------
@@ -141,12 +140,10 @@
 	 * @access	public
 	 * @return	void
 	 */
-	function serve()
+	public function serve()
 	{
 		$r = $this->parseRequest();
-		$payload  = '<?xml version="1.0" encoding="'.$this->xmlrpc_defencoding.'"?'.'>'."\n";
-		$payload .= $this->debug_msg;
-		$payload .= $r->prepare_response();
+		$payload = '<?xml version="1.0" encoding="'.$this->xmlrpc_defencoding.'"?'.'>'."\n".$this->debug_msg.$r->prepare_response();
 
 		header("Content-Type: text/xml");
 		header("Content-Length: ".strlen($payload));
@@ -165,7 +162,7 @@
 	 * @param	string	docstring
 	 * @return	void
 	 */
-	function add_to_map($methodname, $function, $sig, $doc)
+	public function add_to_map($methodname, $function, $sig, $doc)
 	{
 		$this->methods[$methodname] = array(
 			'function'  => $function,
@@ -183,7 +180,7 @@
 	 * @param	string	data
 	 * @return	object	xmlrpc response
 	 */
-	function parseRequest($data='')
+	public function parseRequest($data = '')
 	{
 		global $HTTP_RAW_POST_DATA;
 
@@ -203,13 +200,14 @@
 		$parser = xml_parser_create($this->xmlrpc_defencoding);
 		$parser_object = new XML_RPC_Message("filler");
 
-		$parser_object->xh[$parser]					= array();
-		$parser_object->xh[$parser]['isf']			= 0;
-		$parser_object->xh[$parser]['isf_reason']	= '';
-		$parser_object->xh[$parser]['params']		= array();
-		$parser_object->xh[$parser]['stack']		= array();
-		$parser_object->xh[$parser]['valuestack']	= array();
-		$parser_object->xh[$parser]['method']		= '';
+		$parser_object->xh[$parser] = array(
+							'isf' =>	0,
+							'isf_reason' =>	'',
+							'params' =>	array(),
+							'stack' =>	array(),
+							'valuestack' =>	array(),
+							'method' =>	''
+						);
 
 		xml_set_object($parser, $parser_object);
 		xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
@@ -243,7 +241,7 @@
 			$m = new XML_RPC_Message($parser_object->xh[$parser]['method']);
 			$plist='';
 
-			for ($i=0; $i < count($parser_object->xh[$parser]['params']); $i++)
+			for ($i = 0, $c = count($parser_object->xh[$parser]['params']); $i < $c; $i++)
 			{
 				if ($this->debug === TRUE)
 				{
@@ -255,9 +253,7 @@
 
 			if ($this->debug === TRUE)
 			{
-				echo "<pre>";
-				echo "---PLIST---\n" . $plist . "\n---PLIST END---\n\n";
-				echo "</pre>";
+				echo "<pre>---PLIST---\n".$plist."\n---PLIST END---\n\n</pre>";
 			}
 
 			$r = $this->_execute($m);
@@ -284,12 +280,12 @@
 	 * @param	object
 	 * @return	mixed
 	 */
-	function _execute($m)
+	protected function _execute($m)
 	{
 		$methName = $m->method_name;
 
 		// Check to see if it is a system call
-		$system_call = (strncmp($methName, 'system', 5) == 0) ? TRUE : FALSE;
+		$system_call = (strncmp($methName, 'system', 5) === 0);
 
 		if ($this->xss_clean == FALSE)
 		{
@@ -310,22 +306,20 @@
 		//-------------------------------------
 
 		$method_parts = explode(".", $this->methods[$methName]['function']);
-		$objectCall = (isset($method_parts['1']) && $method_parts['1'] != "") ? TRUE : FALSE;
+		$objectCall = (isset($method_parts[1]) && $method_parts[1] != '');
 
 		if ($system_call === TRUE)
 		{
-			if ( ! is_callable(array($this,$method_parts['1'])))
+			if ( ! is_callable(array($this,$method_parts[1])))
 			{
 				return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
 			}
 		}
 		else
 		{
-			if ($objectCall && ! is_callable(array($method_parts['0'],$method_parts['1'])))
-			{
-				return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
-			}
-			elseif ( ! $objectCall && ! is_callable($this->methods[$methName]['function']))
+			if (($objectCall AND ! is_callable(array($method_parts[0], $method_parts[1])))
+				OR ( ! $objectCall AND ! is_callable($this->methods[$methName]['function']))
+			)
 			{
 				return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
 			}
@@ -338,13 +332,13 @@
 		if (isset($this->methods[$methName]['signature']))
 		{
 			$sig = $this->methods[$methName]['signature'];
-			for ($i=0; $i<count($sig); $i++)
+			for ($i = 0, $c = count($sig); $i < $c; $i++)
 			{
 				$current_sig = $sig[$i];
 
-				if (count($current_sig) == count($m->params)+1)
+				if (count($current_sig) === count($m->params)+1)
 				{
-					for ($n=0; $n < count($m->params); $n++)
+					for ($n = 0, $mc = count($m->params); $n < $mc; $n++)
 					{
 						$p = $m->params[$n];
 						$pt = ($p->kindOf() == 'scalar') ? $p->scalarval() : $p->kindOf();
@@ -370,7 +364,7 @@
 
 		if ($objectCall === TRUE)
 		{
-			if ($method_parts[0] == "this" && $system_call == TRUE)
+			if ($method_parts[0] === 'this' && $system_call === TRUE)
 			{
 				return call_user_func(array($this, $method_parts[1]), $m);
 			}
@@ -379,11 +373,11 @@
 				if ($this->object === FALSE)
 				{
 					$CI =& get_instance();
-					return $CI->$method_parts['1']($m);
+					return $CI->$method_parts[1]($m);
 				}
 				else
 				{
-					return $this->object->$method_parts['1']($m);
+					return $this->object->$method_parts[1]($m);
 					//return call_user_func(array(&$method_parts['0'],$method_parts['1']), $m);
 				}
 			}
@@ -393,7 +387,7 @@
 			return call_user_func($this->methods[$methName]['function'], $m);
 		}
 	}
-	
+
 	// --------------------------------------------------------------------
 
 	/**
@@ -403,7 +397,7 @@
 	 * @param	mixed
 	 * @return	object
 	 */
-	function listMethods($m)
+	public function listMethods($m)
 	{
 		$v = new XML_RPC_Values();
 		$output = array();
@@ -421,7 +415,7 @@
 		$v->addArray($output);
 		return new XML_RPC_Response($v);
 	}
-	
+
 	// --------------------------------------------------------------------
 
 	/**
@@ -431,7 +425,7 @@
 	 * @param	mixed
 	 * @return	object
 	 */
-	function methodSignature($m)
+	public function methodSignature($m)
 	{
 		$parameters = $m->output_parameters();
 		$method_name = $parameters[0];
@@ -443,15 +437,15 @@
 				$sigs = array();
 				$signature = $this->methods[$method_name]['signature'];
 
-				for ($i=0; $i < count($signature); $i++)
+				for ($i = 0, $c = count($signature); $i < $c; $i++)
 				{
 					$cursig = array();
 					$inSig = $signature[$i];
-					for ($j=0; $j<count($inSig); $j++)
+					for ($j = 0, $jc = count($inSig); $j < $jc; $j++)
 					{
 						$cursig[]= new XML_RPC_Values($inSig[$j], 'string');
 					}
-					$sigs[]= new XML_RPC_Values($cursig, 'array');
+					$sigs[] = new XML_RPC_Values($cursig, 'array');
 				}
 				$r = new XML_RPC_Response(new XML_RPC_Values($sigs, 'array'));
 			}
@@ -476,7 +470,7 @@
 	 * @param	mixed
 	 * @return	object
 	 */
-	function methodHelp($m)
+	public function methodHelp($m)
 	{
 		$parameters = $m->output_parameters();
 		$method_name = $parameters[0];
@@ -492,7 +486,7 @@
 			return new XML_RPC_Response(0, $this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']);
 		}
 	}
-	
+
 	// --------------------------------------------------------------------
 
 	/**
@@ -502,7 +496,7 @@
 	 * @param	mixed
 	 * @return	object
 	 */
-	function multicall($m)
+	public function multicall($m)
 	{
 		// Disabled
 		return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
@@ -519,7 +513,7 @@
 			$m = new XML_RPC_Message($value[0]);
 			$plist='';
 
-			for ($i=0; $i < count($value[1]); $i++)
+			for ($i = 0, $c = count($value[1]); $i < $c; $i++)
 			{
 				$m->addParam(new XML_RPC_Values($value[1][$i], 'string'));
 			}
@@ -546,7 +540,7 @@
 	 * @param	mixed
 	 * @return	object
 	 */
-	function multicall_error($err)
+	public function multicall_error($err)
 	{
 		$str  = is_string($err) ? $this->xmlrpcstr["multicall_${err}"] : $err->faultString();
 		$code = is_string($err) ? $this->xmlrpcerr["multicall_${err}"] : $err->faultCode();
@@ -566,7 +560,7 @@
 	 * @param	mixed
 	 * @return	object
 	 */
-	function do_multicall($call)
+	public function do_multicall($call)
 	{
 		if ($call->kindOf() != 'struct')
 		{
@@ -597,11 +591,10 @@
 			return $this->multicall_error('notarray');
 		}
 
-		list($a,$b)=each($params->me);
-		$numParams = count($b);
+		list($a,$b) = each($params->me);
 
 		$msg = new XML_RPC_Message($scalar_value);
-		for ($i = 0; $i < $numParams; $i++)
+		for ($i = 0, $numParams = count($b); $i < $numParams; $i++)
 		{
 			$msg->params[] = $params->me['array'][$i];
 		}
@@ -619,6 +612,5 @@
 }
 // END XML_RPC_Server class
 
-
 /* End of file Xmlrpcs.php */
-/* Location: ./system/libraries/Xmlrpcs.php */
\ No newline at end of file
+/* Location: ./system/libraries/Xmlrpcs.php */
diff --git a/system/libraries/javascript/Jquery.php b/system/libraries/javascript/Jquery.php
index 4b8f76a..888e89b 100644
--- a/system/libraries/javascript/Jquery.php
+++ b/system/libraries/javascript/Jquery.php
@@ -1,13 +1,13 @@
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 /**
  * CodeIgniter
  *
  * An open source application development framework for PHP 5.1.6 or newer
  *
  * NOTICE OF LICENSE
- * 
+ *
  * Licensed under the Open Software License version 3.0
- * 
+ *
  * This source file is subject to the Open Software License (OSL 3.0) that is
  * bundled with this package in the files license.txt / license.rst.  It is
  * also available through the world wide web at this URL:
@@ -36,80 +36,77 @@
  * @author		EllisLab Dev Team
  * @link		http://codeigniter.com/user_guide/libraries/javascript.html
  */
- 
+
 class CI_Jquery extends CI_Javascript {
 
-	var $_javascript_folder = 'js';
-	var $jquery_code_for_load = array();
-	var $jquery_code_for_compile = array();
-	var $jquery_corner_active = FALSE;
-	var $jquery_table_sorter_active = FALSE;
-	var $jquery_table_sorter_pager_active = FALSE;
-	var $jquery_ajax_img = '';
+	protected $_javascript_folder = 'js';
+	public $jquery_code_for_load = array();
+	public $jquery_code_for_compile = array();
+	public $jquery_corner_active = FALSE;
+	public $jquery_table_sorter_active = FALSE;
+	public $jquery_table_sorter_pager_active = FALSE;
+	public $jquery_ajax_img = '';
 
 	public function __construct($params)
 	{
-		$this->CI =& get_instance();	
+		$this->CI =& get_instance();
 		extract($params);
 
 		if ($autoload === TRUE)
 		{
-			$this->script();			
+			$this->script();
 		}
-		
+
 		log_message('debug', "Jquery Class Initialized");
 	}
-	
-	// --------------------------------------------------------------------	 
+
+	// --------------------------------------------------------------------
 	// Event Code
-	// --------------------------------------------------------------------	
+	// --------------------------------------------------------------------
 
 	/**
 	 * Blur
 	 *
 	 * Outputs a jQuery blur event
 	 *
-	 * @access	private
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function _blur($element = 'this', $js = '')
+	protected function _blur($element = 'this', $js = '')
 	{
 		return $this->_add_event($element, $js, 'blur');
 	}
-	
+
 	// --------------------------------------------------------------------
-	
+
 	/**
 	 * Change
 	 *
 	 * Outputs a jQuery change event
 	 *
-	 * @access	private
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function _change($element = 'this', $js = '')
+	protected function _change($element = 'this', $js = '')
 	{
 		return $this->_add_event($element, $js, 'change');
 	}
-	
+
 	// --------------------------------------------------------------------
-	
+
 	/**
 	 * Click
 	 *
 	 * Outputs a jQuery click event
 	 *
-	 * @access	private
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @param	boolean	whether or not to return false
 	 * @return	string
 	 */
-	function _click($element = 'this', $js = '', $ret_false = TRUE)
+	protected function _click($element = 'this', $js = '', $ret_false = TRUE)
 	{
 		if ( ! is_array($js))
 		{
@@ -125,70 +122,66 @@
 	}
 
 	// --------------------------------------------------------------------
-	
+
 	/**
 	 * Double Click
 	 *
 	 * Outputs a jQuery dblclick event
 	 *
-	 * @access	private
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function _dblclick($element = 'this', $js = '')
+	protected function _dblclick($element = 'this', $js = '')
 	{
 		return $this->_add_event($element, $js, 'dblclick');
 	}
 
 	// --------------------------------------------------------------------
-	
+
 	/**
 	 * Error
 	 *
 	 * Outputs a jQuery error event
 	 *
-	 * @access	private
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function _error($element = 'this', $js = '')
+	protected function _error($element = 'this', $js = '')
 	{
 		return $this->_add_event($element, $js, 'error');
 	}
 
 	// --------------------------------------------------------------------
-	
+
 	/**
 	 * Focus
 	 *
 	 * Outputs a jQuery focus event
 	 *
-	 * @access	private
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function _focus($element = 'this', $js = '')
+	protected function _focus($element = 'this', $js = '')
 	{
 		return $this->_add_event($element, $js, 'focus');
 	}
 
 	// --------------------------------------------------------------------
-	
+
 	/**
 	 * Hover
 	 *
 	 * Outputs a jQuery hover event
 	 *
-	 * @access	private
 	 * @param	string	- element
 	 * @param	string	- Javascript code for mouse over
 	 * @param	string	- Javascript code for mouse out
 	 * @return	string
 	 */
-	function _hover($element = 'this', $over, $out)
+	protected function _hover($element = 'this', $over, $out)
 	{
 		$event = "\n\t$(" . $this->_prep_element($element) . ").hover(\n\t\tfunction()\n\t\t{\n\t\t\t{$over}\n\t\t}, \n\t\tfunction()\n\t\t{\n\t\t\t{$out}\n\t\t});\n";
 
@@ -198,103 +191,97 @@
 	}
 
 	// --------------------------------------------------------------------
-	
+
 	/**
 	 * Keydown
 	 *
 	 * Outputs a jQuery keydown event
 	 *
-	 * @access	private
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function _keydown($element = 'this', $js = '')
+	protected function _keydown($element = 'this', $js = '')
 	{
 		return $this->_add_event($element, $js, 'keydown');
 	}
 
 	// --------------------------------------------------------------------
-	
+
 	/**
 	 * Keyup
 	 *
 	 * Outputs a jQuery keydown event
 	 *
-	 * @access	private
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function _keyup($element = 'this', $js = '')
+	protected function _keyup($element = 'this', $js = '')
 	{
 		return $this->_add_event($element, $js, 'keyup');
-	}	
+	}
 
 	// --------------------------------------------------------------------
-	
+
 	/**
 	 * Load
 	 *
 	 * Outputs a jQuery load event
 	 *
-	 * @access	private
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function _load($element = 'this', $js = '')
+	protected function _load($element = 'this', $js = '')
 	{
 		return $this->_add_event($element, $js, 'load');
-	}	
-	
+	}
+
 	// --------------------------------------------------------------------
-	
+
 	/**
 	 * Mousedown
 	 *
 	 * Outputs a jQuery mousedown event
 	 *
-	 * @access	private
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function _mousedown($element = 'this', $js = '')
+	protected function _mousedown($element = 'this', $js = '')
 	{
 		return $this->_add_event($element, $js, 'mousedown');
 	}
 
 	// --------------------------------------------------------------------
-	
+
 	/**
 	 * Mouse Out
 	 *
 	 * Outputs a jQuery mouseout event
 	 *
-	 * @access	private
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function _mouseout($element = 'this', $js = '')
+	protected function _mouseout($element = 'this', $js = '')
 	{
 		return $this->_add_event($element, $js, 'mouseout');
 	}
 
 	// --------------------------------------------------------------------
-	
+
 	/**
 	 * Mouse Over
 	 *
 	 * Outputs a jQuery mouseover event
 	 *
-	 * @access	private
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function _mouseover($element = 'this', $js = '')
+	protected function _mouseover($element = 'this', $js = '')
 	{
 		return $this->_add_event($element, $js, 'mouseover');
 	}
@@ -306,12 +293,11 @@
 	 *
 	 * Outputs a jQuery mouseup event
 	 *
-	 * @access	private
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function _mouseup($element = 'this', $js = '')
+	protected function _mouseup($element = 'this', $js = '')
 	{
 		return $this->_add_event($element, $js, 'mouseup');
 	}
@@ -323,18 +309,17 @@
 	 *
 	 * Outputs script directly
 	 *
-	 * @access	private
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function _output($array_js = '')
+	protected function _output($array_js = '')
 	{
 		if ( ! is_array($array_js))
 		{
 			$array_js = array($array_js);
 		}
-		
+
 		foreach ($array_js as $js)
 		{
 			$this->jquery_code_for_compile[] = "\t$js\n";
@@ -348,12 +333,11 @@
 	 *
 	 * Outputs a jQuery resize event
 	 *
-	 * @access	private
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function _resize($element = 'this', $js = '')
+	protected function _resize($element = 'this', $js = '')
 	{
 		return $this->_add_event($element, $js, 'resize');
 	}
@@ -365,16 +349,15 @@
 	 *
 	 * Outputs a jQuery scroll event
 	 *
-	 * @access	private
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function _scroll($element = 'this', $js = '')
+	protected function _scroll($element = 'this', $js = '')
 	{
 		return $this->_add_event($element, $js, 'scroll');
 	}
-	
+
 	// --------------------------------------------------------------------
 
 	/**
@@ -382,34 +365,31 @@
 	 *
 	 * Outputs a jQuery unload event
 	 *
-	 * @access	private
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @return	string
 	 */
-	function _unload($element = 'this', $js = '')
+	protected function _unload($element = 'this', $js = '')
 	{
 		return $this->_add_event($element, $js, 'unload');
 	}
 
-	// --------------------------------------------------------------------	 
+	// --------------------------------------------------------------------
 	// Effects
-	// --------------------------------------------------------------------	
-	
+	// --------------------------------------------------------------------
+
 	/**
 	 * Add Class
 	 *
 	 * Outputs a jQuery addClass event
 	 *
-	 * @access	private
 	 * @param	string	- element
 	 * @return	string
 	 */
-	function _addClass($element = 'this', $class='')
+	protected function _addClass($element = 'this', $class='')
 	{
 		$element = $this->_prep_element($element);
-		$str  = "$({$element}).addClass(\"$class\");";
-		return $str;
+		return "$({$element}).addClass(\"$class\");";
 	}
 
 	// --------------------------------------------------------------------
@@ -419,19 +399,18 @@
 	 *
 	 * Outputs a jQuery animate event
 	 *
-	 * @access	private
 	 * @param	string	- element
 	 * @param	string	- One of 'slow', 'normal', 'fast', or time in milliseconds
 	 * @param	string	- Javascript callback function
 	 * @return	string
 	 */
-	function _animate($element = 'this', $params = array(), $speed = '', $extra = '')
+	protected function _animate($element = 'this', $params = array(), $speed = '', $extra = '')
 	{
 		$element = $this->_prep_element($element);
 		$speed = $this->_validate_speed($speed);
-		
+
 		$animations = "\t\t\t";
-		
+
 		foreach ($params as $param=>$value)
 		{
 			$animations .= $param.': \''.$value.'\', ';
@@ -443,71 +422,63 @@
 		{
 			$speed = ', '.$speed;
 		}
-		
+
 		if ($extra != '')
 		{
 			$extra = ', '.$extra;
 		}
-		
-		$str  = "$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.");";
-		
-		return $str;
+
+		return "$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.");";
 	}
 
 	// --------------------------------------------------------------------
-		
+
 	/**
 	 * Fade In
 	 *
 	 * Outputs a jQuery hide event
 	 *
-	 * @access	private
 	 * @param	string	- element
 	 * @param	string	- One of 'slow', 'normal', 'fast', or time in milliseconds
 	 * @param	string	- Javascript callback function
 	 * @return	string
 	 */
-	function _fadeIn($element = 'this', $speed = '', $callback = '')
+	protected function _fadeIn($element = 'this', $speed = '', $callback = '')
 	{
-		$element = $this->_prep_element($element);	
+		$element = $this->_prep_element($element);
 		$speed = $this->_validate_speed($speed);
-		
+
 		if ($callback != '')
 		{
 			$callback = ", function(){\n{$callback}\n}";
 		}
-		
-		$str  = "$({$element}).fadeIn({$speed}{$callback});";
-		
-		return $str;
+
+		return "$({$element}).fadeIn({$speed}{$callback});";
 	}
-		
+
 	// --------------------------------------------------------------------
-	
+
 	/**
 	 * Fade Out
 	 *
 	 * Outputs a jQuery hide event
 	 *
-	 * @access	private
 	 * @param	string	- element
 	 * @param	string	- One of 'slow', 'normal', 'fast', or time in milliseconds
 	 * @param	string	- Javascript callback function
 	 * @return	string
 	 */
-	function _fadeOut($element = 'this', $speed = '', $callback = '')
+	protected function _fadeOut($element = 'this', $speed = '', $callback = '')
 	{
 		$element = $this->_prep_element($element);
 		$speed = $this->_validate_speed($speed);
-		
+
 		if ($callback != '')
 		{
 			$callback = ", function(){\n{$callback}\n}";
 		}
-		
-		$str  = "$({$element}).fadeOut({$speed}{$callback});";
-		
-		return $str;
+
+		return "$({$element}).fadeOut({$speed}{$callback});";
 	}
 
 	// --------------------------------------------------------------------
@@ -517,27 +488,24 @@
 	 *
 	 * Outputs a jQuery hide action
 	 *
-	 * @access	private
 	 * @param	string	- element
 	 * @param	string	- One of 'slow', 'normal', 'fast', or time in milliseconds
 	 * @param	string	- Javascript callback function
 	 * @return	string
 	 */
-	function _hide($element = 'this', $speed = '', $callback = '')
+	protected function _hide($element = 'this', $speed = '', $callback = '')
 	{
-		$element = $this->_prep_element($element);	
+		$element = $this->_prep_element($element);
 		$speed = $this->_validate_speed($speed);
-		
+
 		if ($callback != '')
 		{
 			$callback = ", function(){\n{$callback}\n}";
 		}
-		
-		$str  = "$({$element}).hide({$speed}{$callback});";
 
-		return $str;
+		return "$({$element}).hide({$speed}{$callback});";
 	}
-	
+
 	// --------------------------------------------------------------------
 
 	/**
@@ -545,163 +513,145 @@
 	 *
 	 * Outputs a jQuery remove class event
 	 *
-	 * @access	private
 	 * @param	string	- element
 	 * @return	string
 	 */
-	function _removeClass($element = 'this', $class='')
+	protected function _removeClass($element = 'this', $class='')
 	{
 		$element = $this->_prep_element($element);
-		$str  = "$({$element}).removeClass(\"$class\");";
-		return $str;
+		return "$({$element}).removeClass(\"$class\");";
 	}
 
 	// --------------------------------------------------------------------
-			
+
 	/**
 	 * Slide Up
 	 *
 	 * Outputs a jQuery slideUp event
 	 *
-	 * @access	private
 	 * @param	string	- element
 	 * @param	string	- One of 'slow', 'normal', 'fast', or time in milliseconds
 	 * @param	string	- Javascript callback function
 	 * @return	string
 	 */
-	function _slideUp($element = 'this', $speed = '', $callback = '')
+	protected function _slideUp($element = 'this', $speed = '', $callback = '')
 	{
-		$element = $this->_prep_element($element);	
+		$element = $this->_prep_element($element);
 		$speed = $this->_validate_speed($speed);
-		
+
 		if ($callback != '')
 		{
 			$callback = ", function(){\n{$callback}\n}";
 		}
-		
-		$str  = "$({$element}).slideUp({$speed}{$callback});";
-		
-		return $str;
+
+		return "$({$element}).slideUp({$speed}{$callback});";
 	}
-		
+
 	// --------------------------------------------------------------------
-	
+
 	/**
 	 * Slide Down
 	 *
 	 * Outputs a jQuery slideDown event
 	 *
-	 * @access	private
 	 * @param	string	- element
 	 * @param	string	- One of 'slow', 'normal', 'fast', or time in milliseconds
 	 * @param	string	- Javascript callback function
 	 * @return	string
 	 */
-	function _slideDown($element = 'this', $speed = '', $callback = '')
+	protected function _slideDown($element = 'this', $speed = '', $callback = '')
 	{
 		$element = $this->_prep_element($element);
 		$speed = $this->_validate_speed($speed);
-		
+
 		if ($callback != '')
 		{
 			$callback = ", function(){\n{$callback}\n}";
 		}
-		
-		$str  = "$({$element}).slideDown({$speed}{$callback});";
-		
-		return $str;
+
+		return "$({$element}).slideDown({$speed}{$callback});";
 	}
 
 	// --------------------------------------------------------------------
-	
+
 	/**
 	 * Slide Toggle
 	 *
 	 * Outputs a jQuery slideToggle event
 	 *
-	 * @access	public
 	 * @param	string	- element
 	 * @param	string	- One of 'slow', 'normal', 'fast', or time in milliseconds
 	 * @param	string	- Javascript callback function
 	 * @return	string
 	 */
-	function _slideToggle($element = 'this', $speed = '', $callback = '')
+	protected function _slideToggle($element = 'this', $speed = '', $callback = '')
 	{
 		$element = $this->_prep_element($element);
 		$speed = $this->_validate_speed($speed);
-		
+
 		if ($callback != '')
 		{
 			$callback = ", function(){\n{$callback}\n}";
 		}
-		
-		$str  = "$({$element}).slideToggle({$speed}{$callback});";
-		
-		return $str;
+
+		return "$({$element}).slideToggle({$speed}{$callback});";
 	}
-		
+
 	// --------------------------------------------------------------------
-	
+
 	/**
 	 * Toggle
 	 *
 	 * Outputs a jQuery toggle event
 	 *
-	 * @access	private
 	 * @param	string	- element
 	 * @return	string
 	 */
-	function _toggle($element = 'this')
+	protected function _toggle($element = 'this')
 	{
 		$element = $this->_prep_element($element);
-		$str  = "$({$element}).toggle();";
-		return $str;
+		return "$({$element}).toggle();";
 	}
-	
+
 	// --------------------------------------------------------------------
-	
+
 	/**
 	 * Toggle Class
 	 *
 	 * Outputs a jQuery toggle class event
 	 *
-	 * @access	private
 	 * @param	string	- element
 	 * @return	string
 	 */
-	function _toggleClass($element = 'this', $class='')
+	protected function _toggleClass($element = 'this', $class='')
 	{
 		$element = $this->_prep_element($element);
-		$str  = "$({$element}).toggleClass(\"$class\");";
-		return $str;
+		return "$({$element}).toggleClass(\"$class\");";
 	}
-	
+
 	// --------------------------------------------------------------------
-	
+
 	/**
 	 * Show
 	 *
 	 * Outputs a jQuery show event
 	 *
-	 * @access	private
 	 * @param	string	- element
 	 * @param	string	- One of 'slow', 'normal', 'fast', or time in milliseconds
 	 * @param	string	- Javascript callback function
 	 * @return	string
 	 */
-	function _show($element = 'this', $speed = '', $callback = '')
+	protected function _show($element = 'this', $speed = '', $callback = '')
 	{
-		$element = $this->_prep_element($element);	
+		$element = $this->_prep_element($element);
 		$speed = $this->_validate_speed($speed);
-		
+
 		if ($callback != '')
 		{
 			$callback = ", function(){\n{$callback}\n}";
 		}
-		
-		$str  = "$({$element}).show({$speed}{$callback});";
-		
-		return $str;
+
+		return "$({$element}).show({$speed}{$callback});";
 	}
 
 	// --------------------------------------------------------------------
@@ -709,22 +659,20 @@
 	/**
 	 * Updater
 	 *
-	 * An Ajax call that populates the designated DOM node with 
+	 * An Ajax call that populates the designated DOM node with
 	 * returned content
 	 *
-	 * @access	private
 	 * @param	string	The element to attach the event to
 	 * @param	string	the controller to run the call against
 	 * @param	string	optional parameters
 	 * @return	string
 	 */
-	
-	function _updater($container = 'this', $controller, $options = '')
-	{	
+
+	protected function _updater($container = 'this', $controller, $options = '')
+	{
 		$container = $this->_prep_element($container);
-		
 		$controller = (strpos('://', $controller) === FALSE) ? $controller : $this->CI->config->site_url($controller);
-		
+
 		// ajaxStart and ajaxStop are better choices here... but this is a stop gap
 		if ($this->CI->config->item('javascript_ajax_img') == '')
 		{
@@ -732,41 +680,38 @@
 		}
 		else
 		{
-			$loading_notifier = '<img src=\'' . $this->CI->config->slash_item('base_url') . $this->CI->config->item('javascript_ajax_img') . '\' alt=\'Loading\' />';
+			$loading_notifier = '<img src=\''.$this->CI->config->slash_item('base_url').$this->CI->config->item('javascript_ajax_img').'\' alt=\'Loading\' />';
 		}
-		
-		$updater = "$($container).empty();\n"; // anything that was in... get it out
-		$updater .= "\t\t$($container).prepend(\"$loading_notifier\");\n"; // to replace with an image
+
+		$updater = "$($container).empty();\n" // anything that was in... get it out
+			. "\t\t$($container).prepend(\"$loading_notifier\");\n"; // to replace with an image
 
 		$request_options = '';
 		if ($options != '')
 		{
-			$request_options .= ", {";
-			$request_options .= (is_array($options)) ? "'".implode("', '", $options)."'" : "'".str_replace(":", "':'", $options)."'";
-			$request_options .= "}";
+			$request_options .= ', {'
+					. (is_array($options) ? "'".implode("', '", $options)."'" : "'".str_replace(":", "':'", $options)."'")
+					. '}';
 		}
 
-		$updater .= "\t\t$($container).load('$controller'$request_options);";
-		return $updater;
+		return $updater."\t\t$($container).load('$controller'$request_options);";
 	}
 
 
 	// --------------------------------------------------------------------
 	// Pre-written handy stuff
 	// --------------------------------------------------------------------
-	 
+
 	/**
 	 * Zebra tables
 	 *
-	 * @access	private
 	 * @param	string	table name
 	 * @param	string	plugin location
 	 * @return	string
 	 */
-	function _zebraTables($class = '', $odd = 'odd', $hover = '')
+	protected function _zebraTables($class = '', $odd = 'odd', $hover = '')
 	{
 		$class = ($class != '') ? '.'.$class : '';
-		
 		$zebra  = "\t\$(\"table{$class} tbody tr:nth-child(even)\").addClass(\"{$odd}\");";
 
 		$this->jquery_code_for_compile[] = $zebra;
@@ -779,22 +724,19 @@
 		return $zebra;
 	}
 
-
-
 	// --------------------------------------------------------------------
 	// Plugins
 	// --------------------------------------------------------------------
-	
+
 	/**
 	 * Corner Plugin
 	 *
 	 * http://www.malsup.com/jquery/corner/
 	 *
-	 * @access	public
 	 * @param	string	target
 	 * @return	string
 	 */
-	function corner($element = '', $corner_style = '')
+	public function corner($element = '', $corner_style = '')
 	{
 		// may want to make this configurable down the road
 		$corner_location = '/plugins/jquery.corner.js';
@@ -806,7 +748,7 @@
 
 		return "$(" . $this->_prep_element($element) . ").corner(".$corner_style.");";
 	}
-	
+
 	// --------------------------------------------------------------------
 
 	/**
@@ -814,11 +756,10 @@
 	 *
 	 * Load a thickbox modal window
 	 *
-	 * @access	public
 	 * @return	void
 	 */
-	function modal($src, $relative = FALSE)
-	{	
+	public function modal($src, $relative = FALSE)
+	{
 		$this->jquery_code_for_load[] = $this->external($src, $relative);
 	}
 
@@ -829,10 +770,9 @@
 	 *
 	 * Load an Effect library
 	 *
-	 * @access	public
 	 * @return	void
 	 */
-	function effect($src, $relative = FALSE)
+	public function effect($src, $relative = FALSE)
 	{
 		$this->jquery_code_for_load[] = $this->external($src, $relative);
 	}
@@ -844,10 +784,9 @@
 	 *
 	 * Load a plugin library
 	 *
-	 * @access	public
 	 * @return	void
 	 */
-	function plugin($src, $relative = FALSE)
+	public function plugin($src, $relative = FALSE)
 	{
 		$this->jquery_code_for_load[] = $this->external($src, $relative);
 	}
@@ -859,10 +798,9 @@
 	 *
 	 * Load a user interface library
 	 *
-	 * @access	public
 	 * @return	void
 	 */
-	function ui($src, $relative = FALSE)
+	public function ui($src, $relative = FALSE)
 	{
 		$this->jquery_code_for_load[] = $this->external($src, $relative);
 	}
@@ -873,10 +811,9 @@
 	 *
 	 * Creates a jQuery sortable
 	 *
-	 * @access	public
 	 * @return	void
 	 */
-	function sortable($element, $options = array())
+	public function sortable($element, $options = array())
 	{
 
 		if (count($options) > 0)
@@ -901,16 +838,15 @@
 	/**
 	 * Table Sorter Plugin
 	 *
-	 * @access	public
 	 * @param	string	table name
 	 * @param	string	plugin location
 	 * @return	string
 	 */
-	function tablesorter($table = '', $options = '')
+	public function tablesorter($table = '', $options = '')
 	{
 		$this->jquery_code_for_compile[] = "\t$(" . $this->_prep_element($table) . ").tablesorter($options);\n";
 	}
-	
+
 	// --------------------------------------------------------------------
 	// Class functions
 	// --------------------------------------------------------------------
@@ -920,13 +856,12 @@
 	 *
 	 * Constructs the syntax for an event, and adds to into the array for compilation
 	 *
-	 * @access	private
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
 	 * @param	string	The event to pass
 	 * @return	string
-	 */	
-	function _add_event($element, $js, $event)
+	 */
+	protected function _add_event($element, $js, $event)
 	{
 		if (is_array($js))
 		{
@@ -947,65 +882,61 @@
 	 * As events are specified, they are stored in an array
 	 * This funciton compiles them all for output on a page
 	 *
-	 * @access	private
 	 * @return	string
 	 */
-	function _compile($view_var = 'script_foot', $script_tags = TRUE)
+	protected function _compile($view_var = 'script_foot', $script_tags = TRUE)
 	{
 		// External references
 		$external_scripts = implode('', $this->jquery_code_for_load);
 		$this->CI->load->vars(array('library_src' => $external_scripts));
 
-		if (count($this->jquery_code_for_compile) == 0 )
+		if (count($this->jquery_code_for_compile) === 0)
 		{
 			// no inline references, let's just return
 			return;
 		}
 
 		// Inline references
-		$script = '$(document).ready(function() {' . "\n";
-		$script .= implode('', $this->jquery_code_for_compile);
-		$script .= '});';
-		
+		$script = '$(document).ready(function() {'."\n"
+			. implode('', $this->jquery_code_for_compile)
+			. '});';
+
 		$output = ($script_tags === FALSE) ? $script : $this->inline($script);
 
 		$this->CI->load->vars(array($view_var => $output));
 
 	}
-	
+
 	// --------------------------------------------------------------------
-	
+
 	/**
 	 * Clear Compile
 	 *
 	 * Clears the array of script events collected for output
 	 *
-	 * @access	public
 	 * @return	void
 	 */
-	function _clear_compile()
+	protected function _clear_compile()
 	{
 		$this->jquery_code_for_compile = array();
 	}
 
 	// --------------------------------------------------------------------
-	
+
 	/**
 	 * Document Ready
 	 *
 	 * A wrapper for writing document.ready()
 	 *
-	 * @access	private
 	 * @return	string
 	 */
-	function _document_ready($js)
+	protected function _document_ready($js)
 	{
 		if ( ! is_array($js))
 		{
-			$js = array ($js);
-
+			$js = array($js);
 		}
-		
+
 		foreach ($js as $script)
 		{
 			$this->jquery_code_for_compile[] = $script;
@@ -1019,17 +950,16 @@
 	 *
 	 * Outputs the script tag that loads the jquery.js file into an HTML document
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	string
 	 */
-	function script($library_src = '', $relative = FALSE)
+	public function script($library_src = '', $relative = FALSE)
 	{
 		$library_src = $this->external($library_src, $relative);
 		$this->jquery_code_for_load[] = $library_src;
 		return $library_src;
 	}
-	
+
 	// --------------------------------------------------------------------
 
 	/**
@@ -1039,20 +969,19 @@
 	 * unless the supplied element is the Javascript 'this'
 	 * object, in which case no quotes are added
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	string
 	 */
-	function _prep_element($element)
+	protected function _prep_element($element)
 	{
 		if ($element != 'this')
 		{
 			$element = '"'.$element.'"';
 		}
-		
+
 		return $element;
 	}
-	
+
 	// --------------------------------------------------------------------
 
 	/**
@@ -1060,25 +989,24 @@
 	 *
 	 * Ensures the speed parameter is valid for jQuery
 	 *
-	 * @access	private
 	 * @param	string
 	 * @return	string
-	 */	
-	function _validate_speed($speed)
+	 */
+	protected function _validate_speed($speed)
 	{
 		if (in_array($speed, array('slow', 'normal', 'fast')))
 		{
-			$speed = '"'.$speed.'"';
+			return '"'.$speed.'"';
 		}
 		elseif (preg_match("/[^0-9]/", $speed))
 		{
-			$speed = '';
+			return '';
 		}
-	
+
 		return $speed;
 	}
 
 }
 
 /* End of file Jquery.php */
-/* Location: ./system/libraries/Jquery.php */
\ No newline at end of file
+/* Location: ./system/libraries/Jquery.php */
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 8a7109f..be83f09 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -28,6 +28,7 @@
    -  Added support 3gp, 3g2, mp4, wmv, f4v, vlc Video files to mimes.php.
    -  Added support m4a, aac, m4u, xspf, au, ac3, flac, ogg Audio files to mimes.php.
    -  Changed logger to only chmod when file is first created.
+   -  Removed previously deprecated SHA1 Library.
 
 -  Helpers
 
@@ -41,6 +42,7 @@
       the SQL string of queries without executing them: get_compiled_select(),
       get_compiled_insert(), get_compiled_update(), get_compiled_delete().
    -  Taking care of LIKE condition when used with MySQL UPDATE statement.
+   -  Adding $escape parameter to the order_by function, this enables ordering by custom fields.
 
 -  Libraries
 
@@ -48,16 +50,19 @@
    -  CI_Loader::_ci_autoloader() is now a protected method.
    -  Modified valid_ip() to use PHP's filter_var() when possible (>= PHP 5.2) in the :doc:`Form Validation library <libraries/form_validation>`.
 	 -  Added custom filename to Email::attach() as $this->email->attach($filename, $disposition, $newname)
-   -  Cart library changes include;
+   -  Cart library changes include:
 	 -  It now auto-increments quantity's instead of just resetting it, this is the default behaviour of large e-commerce sites.
 	 -  Product Name strictness can be disabled via the Cart Library by switching "$product_name_safe"
 	 -  Added function remove() to remove a cart item, updating with quantity of 0 seemed like a hack but has remained to retain compatability
+   -  Minor speed optimizations and method & property visibility declarations in the Calendar Library.
+   -  Removed SHA1 function in the :doc:`Encryption Library <libraries/encryption>`.
 
 -  Core
 
    -  Changed private functions in CI_URI to protected so MY_URI can
       override them.
    -  Removed CI_CORE boolean constant from CodeIgniter.php (no longer Reactor and Core versions).
+   -  Added method get_vars() to CI_Loader to retrieve all variables loaded with $this->load->vars()
 
 Bug fixes for 3.0
 ------------------
@@ -67,15 +72,17 @@
    language file.
 -  Fixed a bug (#159, #163) that mishandled Active Record nested transactions because _trans_depth was not getting incremented.
 -  Fixed a bug (#737, #75) where pagination anchor class was not set properly when using initialize method.
--  Bug #419 - auto_link() now recognizes URLs that come after a word boundary.
--  Bug #724 - is_unique in form validation now checks that you are connected to a database.
--  Bug #647 - _get_mod_time() in Zip library no longer generates stat failed errors
--  Bug #608 - Fixes an issue with the Image_lib class not clearing properties completely
+-  Fixed a bug (#419) - auto_link() now recognizes URLs that come after a word boundary.
+-  Fixed a bug (#724) - is_unique in form validation now checks that you are connected to a database.
+-  Fixed a bug (#647) - _get_mod_time() in Zip library no longer generates stat failed errors
+-  Fixed a bug (#608) - Fixes an issue with the Image_lib class not clearing properties completely
 -  Fixed bugs (#157 and #174) - the Image_lib clear() function now resets all variables to their default values.
 -  Fixed a bug where using $this->dbforge->create_table() with PostgreSQL database could lead to fetching whole table.
--  Bug #795 - Fixed form method and accept-charset when passing an empty array.
--  Bug #797 - timespan was using incorrect seconds for year and month.
+-  Fixed a bug (#795) - Fixed form method and accept-charset when passing an empty array.
+-  Fixed a bug (#797) - timespan was using incorrect seconds for year and month.
 -  Fixed a bug in CI_Cart::contents() where if called without a TRUE (or equal) parameter, it would fail due to a typo.
+-  Fixed a bug (#696) - make oci_execute calls inside num_rows non-committing, since they are only there to reset which row is next in line for oci_fetch calls and thus don't need to be committed.
+-  Fixed a bug (#406) - sqlsrv DB driver not reuturning resource on <samp>db_pconnect()</samp>.
 
 Version 2.1.0
 =============
@@ -174,6 +181,7 @@
 -  Fixed a bug (#537) - Support for all wav type in browser.
 -  Fixed a bug (#576) - Using ini_get() function to detect if apc is enabled or not.
 -  Fixed invalid date time format in :doc:`Date helper <helpers/date_helper>` and :doc:`XMLRPC library <libraries/xmlrpc>`.
+-  Fixed a bug (#200) - MySQL queries would be malformed after calling count_all() then db->get().
 
 Version 2.0.3
 =============
diff --git a/user_guide_src/source/database/active_record.rst b/user_guide_src/source/database/active_record.rst
index 228d1d5..1600f0b 100644
--- a/user_guide_src/source/database/active_record.rst
+++ b/user_guide_src/source/database/active_record.rst
@@ -82,7 +82,7 @@
 utilize `$this->db->from()`_ and did not pass a table name into the first 
 parameter. The reason for this outcome is because the query has not been 
 executed using `$this->db->get()`_ which resets values or reset directly 
-using `$this-db->reset_query()`_.
+using `$this->db->reset_query()`_.
 
 
 $this->db->get_where()
@@ -96,8 +96,7 @@
 
 Please read the about the where function below for more information.
 
-.. note:: get_where() was formerly known as getwhere(), which has been
-removed
+.. note:: get_where() was formerly known as getwhere(), which has been removed
 
 $this->db->select()
 ===================
@@ -789,7 +788,7 @@
 This works exactly the same way as ``$this->db->get_compiled_insert()`` except
 that it produces an UPDATE SQL string instead of an INSERT SQL string.
 
-For more information view documentation for `$this->get_compiled_insert()`_.
+For more information view documentation for `$this->db->get_compiled_insert()`_.
 
 
 *************
@@ -864,7 +863,7 @@
 This works exactly the same way as ``$this->db->get_compiled_insert()`` except
 that it produces a DELETE SQL string instead of an INSERT SQL string.
 
-For more information view documentation for `$this->get_compiled_insert()`_.
+For more information view documentation for `$this->db->get_compiled_insert()`_.
 
 ***************
 Method Chaining
@@ -933,10 +932,8 @@
 	where, like, group_by, having, order_by, set
 
 
-
-*******************
-Reset Active Record
-*******************
+$this->db->reset_query()
+========================
 
 Resetting Active Record allows you to start fresh with your query without 
 executing it first using a method like $this->db->get() or $this->db->insert(). 
diff --git a/user_guide_src/source/database/configuration.rst b/user_guide_src/source/database/configuration.rst
index 433c671..4f88c25 100644
--- a/user_guide_src/source/database/configuration.rst
+++ b/user_guide_src/source/database/configuration.rst
@@ -158,6 +158,7 @@
 			while developing an application.
 **port**		The database port number. To use this value you have to add a line to the database config array.
 			::
+			
 				$db['default']['port'] =  5432;
 ======================  ==================================================================================================
 
diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst
new file mode 100644
index 0000000..960485a
--- /dev/null
+++ b/user_guide_src/source/installation/upgrade_300.rst
@@ -0,0 +1,28 @@
+#############################
+Upgrading from 2.1.0 to 3.0.0
+#############################
+
+.. note:: These upgrade notes are for a version that is yet to be released.
+
+
+Before performing an update you should take your site offline by
+replacing the index.php file with a static one.
+
+Step 1: Update your CodeIgniter files
+=====================================
+
+Replace all files and directories in your "system" folder and replace
+your index.php file. If any modifications were made to your index.php
+they will need to be made fresh in this new one.
+
+Step 2: Change References to the SHA Library
+============================================
+
+The previously deprecated SHA library has been removed in CodeIgniter 3.0.
+Alter your code to use the native `sha1()` PHP function to generate a sha1 hash.
+
+Additionally, the `sha1()` method in the :doc:`Encryption Library <../libraries/encryption>` has been removed.
+
+
+.. note:: If you have any custom developed files in these folders please
+	make copies of them first.
diff --git a/user_guide_src/source/libraries/cart.rst b/user_guide_src/source/libraries/cart.rst
index fbf7778..6594b3b 100644
--- a/user_guide_src/source/libraries/cart.rst
+++ b/user_guide_src/source/libraries/cart.rst
@@ -257,7 +257,7 @@
 Permits you to update items in the shopping cart, as outlined above.
 
 $this->cart->remove(rowid);
-**********************
+***************************
 
 Allows you to remove an item from the shopping cart by passing it the rowid.
 
@@ -267,12 +267,12 @@
 Displays the total amount in the cart.
 
 $this->cart->total_items();
-****************************
+***************************
 
 Displays the total number of items in the cart.
 
 $this->cart->contents(boolean);
-************************
+*******************************
 
 Returns an array containing everything in the cart. You can sort the order,
 by which this is returned by passing it "true" where the contents will be sorted
@@ -280,7 +280,7 @@
 first added to the basket to last added to the basket.
 
 $this->cart->has_options(rowid);
-*********************************
+********************************
 
 Returns TRUE (boolean) if a particular row in the cart contains options.
 This function is designed to be used in a loop with
@@ -288,7 +288,7 @@
 as shown in the Displaying the Cart example above.
 
 $this->cart->product_options(rowid);
-*************************************
+************************************
 
 Returns an array of options for a particular product. This function is
 designed to be used in a loop with $this->cart->contents(), since you
diff --git a/user_guide_src/source/libraries/encryption.rst b/user_guide_src/source/libraries/encryption.rst
index 80b45e4..28bdca2 100644
--- a/user_guide_src/source/libraries/encryption.rst
+++ b/user_guide_src/source/libraries/encryption.rst
@@ -126,21 +126,6 @@
 Please visit php.net for a list of `available
 modes <http://php.net/mcrypt>`_.
 
-$this->encrypt->sha1();
-=======================
-
-SHA1 encoding function. Provide a string and it will return a 160 bit
-one way hash. Note: SHA1, just like MD5 is non-decodable. Example::
-
-	$hash = $this->encrypt->sha1('Some string');
-
-Many PHP installations have SHA1 support by default so if all you need
-is to encode a hash it's simpler to use the native function::
-
-	$hash = sha1('Some string');
-
-If your server does not support SHA1 you can use the provided function.
-
 $this->encrypt->encode_from_legacy($orig_data, $legacy_mode = MCRYPT_MODE_ECB, $key = '');
 ==========================================================================================
 
diff --git a/user_guide_src/source/libraries/loader.rst b/user_guide_src/source/libraries/loader.rst
index bbe2ed5..2090404 100644
--- a/user_guide_src/source/libraries/loader.rst
+++ b/user_guide_src/source/libraries/loader.rst
@@ -165,6 +165,12 @@
 your views. This is useful if for any reason a var is set in a library
 or another controller method using $this->load->vars().
 
+$this->load->get_vars()
+===========================
+
+This function retrieves all variables available to
+your views.
+
 $this->load->helper('file_name')
 =================================
 
diff --git a/user_guide_src/source/libraries/migration.rst b/user_guide_src/source/libraries/migration.rst
new file mode 100644
index 0000000..5192f1f
--- /dev/null
+++ b/user_guide_src/source/libraries/migration.rst
@@ -0,0 +1,5 @@
+################
+Migrations Class
+################
+
+Coming soon.
\ No newline at end of file