Merge pull request #1320 from thallisphp/patch-2

Update system/libraries/Cart.php  -  To enable integrity when using associative arrays
diff --git a/application/config/routes.php b/application/config/routes.php
index 474bda9..0011986 100644
--- a/application/config/routes.php
+++ b/application/config/routes.php
@@ -64,7 +64,7 @@
 |
 */
 
-$route['default_controller'] = "welcome";
+$route['default_controller'] = 'welcome';
 $route['404_override'] = '';
 
 /* End of file routes.php */
diff --git a/application/config/user_agents.php b/application/config/user_agents.php
index 60f256e..7611461 100644
--- a/application/config/user_agents.php
+++ b/application/config/user_agents.php
@@ -36,7 +36,7 @@
 |
 */
 
-$platforms = array (
+$platforms = array(
 	'windows nt 6.1'	=> 'Windows 7',
 	'windows nt 6.0'	=> 'Windows Vista',
 	'windows nt 5.2'	=> 'Windows 2003',
@@ -51,6 +51,11 @@
 	'windows 95'		=> 'Windows 95',
 	'win95'				=> 'Windows 95',
 	'windows'			=> 'Unknown Windows OS',
+	'android'			=> 'Android',
+	'blackberry'		=> 'BlackBerry',
+	'iphone'			=> 'iOS',
+	'ipad'				=> 'iOS',
+	'ipod'				=> 'iOS',
 	'os x'				=> 'Mac OS X',
 	'ppc mac'			=> 'Power PC Mac',
 	'freebsd'			=> 'FreeBSD',
@@ -117,84 +122,83 @@
 //	'motorola'			=> 'Motorola'
 
 	// Phones and Manufacturers
-	'motorola'		=> "Motorola",
-	'nokia'			=> "Nokia",
-	'palm'			=> "Palm",
-	'iphone'		=> "Apple iPhone",
-	'ipad'			=> "iPad",
-	'ipod'			=> "Apple iPod Touch",
-	'sony'			=> "Sony Ericsson",
-	'ericsson'		=> "Sony Ericsson",
-	'blackberry'	=> "BlackBerry",
-	'cocoon'		=> "O2 Cocoon",
-	'blazer'		=> "Treo",
-	'lg'			=> "LG",
-	'amoi'			=> "Amoi",
-	'xda'			=> "XDA",
-	'mda'			=> "MDA",
-	'vario'			=> "Vario",
-	'htc'			=> "HTC",
-	'samsung'		=> "Samsung",
-	'sharp'			=> "Sharp",
-	'sie-'			=> "Siemens",
-	'alcatel'		=> "Alcatel",
-	'benq'			=> "BenQ",
-	'ipaq'			=> "HP iPaq",
-	'mot-'			=> "Motorola",
-	'playstation portable'	=> "PlayStation Portable",
-	'hiptop'		=> "Danger Hiptop",
-	'nec-'			=> "NEC",
-	'panasonic'		=> "Panasonic",
-	'philips'		=> "Philips",
-	'sagem'			=> "Sagem",
-	'sanyo'			=> "Sanyo",
-	'spv'			=> "SPV",
-	'zte'			=> "ZTE",
-	'sendo'			=> "Sendo",
-	'dsi'			=> "Nintendo DSi",
-	'ds'			=> "Nintendo DS",
-	'wii'			=> "Nintendo Wii",
-	'3ds'			=> "Nintendo 3DS",
-	'open web'		=> "Open Web",
-	'openweb'		=> "OpenWeb",
+	'motorola'		=> 'Motorola',
+	'nokia'			=> 'Nokia',
+	'palm'			=> 'Palm',
+	'iphone'		=> 'Apple iPhone',
+	'ipad'			=> 'iPad',
+	'ipod'			=> 'Apple iPod Touch',
+	'sony'			=> 'Sony Ericsson',
+	'ericsson'		=> 'Sony Ericsson',
+	'blackberry'	=> 'BlackBerry',
+	'cocoon'		=> 'O2 Cocoon',
+	'blazer'		=> 'Treo',
+	'lg'			=> 'LG',
+	'amoi'			=> 'Amoi',
+	'xda'			=> 'XDA',
+	'mda'			=> 'MDA',
+	'vario'			=> 'Vario',
+	'htc'			=> 'HTC',
+	'samsung'		=> 'Samsung',
+	'sharp'			=> 'Sharp',
+	'sie-'			=> 'Siemens',
+	'alcatel'		=> 'Alcatel',
+	'benq'			=> 'BenQ',
+	'ipaq'			=> 'HP iPaq',
+	'mot-'			=> 'Motorola',
+	'playstation portable'	=> 'PlayStation Portable',
+	'hiptop'		=> 'Danger Hiptop',
+	'nec-'			=> 'NEC',
+	'panasonic'		=> 'Panasonic',
+	'philips'		=> 'Philips',
+	'sagem'			=> 'Sagem',
+	'sanyo'			=> 'Sanyo',
+	'spv'			=> 'SPV',
+	'zte'			=> 'ZTE',
+	'sendo'			=> 'Sendo',
+	'dsi'			=> 'Nintendo DSi',
+	'ds'			=> 'Nintendo DS',
+	'wii'			=> 'Nintendo Wii',
+	'3ds'			=> 'Nintendo 3DS',
+	'open web'		=> 'Open Web',
+	'openweb'		=> 'OpenWeb',
 
 	// Operating Systems
-	'android'		=> "Android",
-	'symbian'		=> "Symbian",
-	'SymbianOS'		=> "SymbianOS",
-	'elaine'		=> "Palm",
-	'palm'			=> "Palm",
-	'series60'		=> "Symbian S60",
-	'windows ce'	=> "Windows CE",
+	'android'		=> 'Android',
+	'symbian'		=> 'Symbian',
+	'SymbianOS'		=> 'SymbianOS',
+	'elaine'		=> 'Palm',
+	'series60'		=> 'Symbian S60',
+	'windows ce'	=> 'Windows CE',
 
 	// Browsers
-	'obigo'			=> "Obigo",
-	'netfront'		=> "Netfront Browser",
-	'openwave'		=> "Openwave Browser",
-	'mobilexplorer'	=> "Mobile Explorer",
-	'operamini'		=> "Opera Mini",
-	'opera mini'	=> "Opera Mini",
-	'opera mobi'	=> "Opera Mobile",
+	'obigo'			=> 'Obigo',
+	'netfront'		=> 'Netfront Browser',
+	'openwave'		=> 'Openwave Browser',
+	'mobilexplorer'	=> 'Mobile Explorer',
+	'operamini'		=> 'Opera Mini',
+	'opera mini'	=> 'Opera Mini',
+	'opera mobi'	=> 'Opera Mobile',
 
 	// Other
-	'digital paths'	=> "Digital Paths",
-	'avantgo'		=> "AvantGo",
-	'xiino'			=> "Xiino",
-	'novarra'		=> "Novarra Transcoder",
-	'vodafone'		=> "Vodafone",
-	'docomo'		=> "NTT DoCoMo",
-	'o2'			=> "O2",
+	'digital paths'	=> 'Digital Paths',
+	'avantgo'		=> 'AvantGo',
+	'xiino'			=> 'Xiino',
+	'novarra'		=> 'Novarra Transcoder',
+	'vodafone'		=> 'Vodafone',
+	'docomo'		=> 'NTT DoCoMo',
+	'o2'			=> 'O2',
 
 	// Fallback
-	'mobile'		=> "Generic Mobile",
-	'wireless'		=> "Generic Mobile",
-	'j2me'			=> "Generic Mobile",
-	'midp'			=> "Generic Mobile",
-	'cldc'			=> "Generic Mobile",
-	'up.link'		=> "Generic Mobile",
-	'up.browser'	=> "Generic Mobile",
-	'smartphone'	=> "Generic Mobile",
-	'cellphone'		=> "Generic Mobile"
+	'mobile'		=> 'Generic Mobile',
+	'wireless'		=> 'Generic Mobile',
+	'j2me'			=> 'Generic Mobile',
+	'midp'			=> 'Generic Mobile',
+	'cldc'			=> 'Generic Mobile',
+	'up.link'		=> 'Generic Mobile',
+	'up.browser'	=> 'Generic Mobile',
+	'smartphone'	=> 'Generic Mobile',
+	'cellphone'		=> 'Generic Mobile'
 );
 
 // There are hundreds of bots but these are the most common.
diff --git a/application/errors/error_404.php b/application/views/errors/error_404.php
similarity index 97%
rename from application/errors/error_404.php
rename to application/views/errors/error_404.php
index 7460329..c19bedf 100644
--- a/application/errors/error_404.php
+++ b/application/views/errors/error_404.php
@@ -72,7 +72,7 @@
 #container {
 	margin: 10px;
 	border: 1px solid #D0D0D0;
-	-webkit-box-shadow: 0 0 8px #D0D0D0;
+	box-shadow: 0 0 8px #D0D0D0;
 }
 
 p {
diff --git a/application/errors/error_db.php b/application/views/errors/error_db.php
similarity index 97%
rename from application/errors/error_db.php
rename to application/views/errors/error_db.php
index eb3a752..3b244e0 100644
--- a/application/errors/error_db.php
+++ b/application/views/errors/error_db.php
@@ -72,7 +72,7 @@
 #container {
 	margin: 10px;
 	border: 1px solid #D0D0D0;
-	-webkit-box-shadow: 0 0 8px #D0D0D0;
+	box-shadow: 0 0 8px #D0D0D0;
 }
 
 p {
diff --git a/application/errors/error_general.php b/application/views/errors/error_general.php
similarity index 97%
rename from application/errors/error_general.php
rename to application/views/errors/error_general.php
index 59896e1..c88afe1 100644
--- a/application/errors/error_general.php
+++ b/application/views/errors/error_general.php
@@ -72,7 +72,7 @@
 #container {
 	margin: 10px;
 	border: 1px solid #D0D0D0;
-	-webkit-box-shadow: 0 0 8px #D0D0D0;
+	box-shadow: 0 0 8px #D0D0D0;
 }
 
 p {
diff --git a/application/errors/error_php.php b/application/views/errors/error_php.php
similarity index 93%
rename from application/errors/error_php.php
rename to application/views/errors/error_php.php
index 3855720..b76dc8a 100644
--- a/application/errors/error_php.php
+++ b/application/views/errors/error_php.php
@@ -40,12 +40,15 @@
 	<p>Backtrace: </p>
 	<?php foreach(debug_backtrace() as $error): ?>
 
-		<?php if(isset($error['file']) &&  ! stristr($error['file'], SYSDIR)): ?>
+		<?php if(isset($error['file']) &&
+		         strpos($error['file'], realpath(BASEPATH)) !== 0): ?>
+
 			<p style="margin-left:10px">
 			File: <?php echo $error['file'] ?><br />
 			Line: <?php echo $error['line'] ?><br />
 			Function: <?php echo $error['function'] ?>
 			</p>
+
 		<?php endif ?>
 
 	<?php endforeach ?></p>
diff --git a/application/errors/index.html b/application/views/errors/index.html
similarity index 100%
rename from application/errors/index.html
rename to application/views/errors/index.html
diff --git a/system/core/Benchmark.php b/system/core/Benchmark.php
index c17e95a..bb630f4 100755
--- a/system/core/Benchmark.php
+++ b/system/core/Benchmark.php
@@ -25,13 +25,11 @@
  * @filesource
  */
 
-// ------------------------------------------------------------------------
-
 /**
  * CodeIgniter Benchmark Class
  *
  * This class enables you to mark points and calculate the time difference
- * between them.  Memory consumption can also be displayed.
+ * between them. Memory consumption can also be displayed.
  *
  * @package		CodeIgniter
  * @subpackage	Libraries
@@ -119,4 +117,4 @@
 }
 
 /* End of file Benchmark.php */
-/* Location: ./system/core/Benchmark.php */
+/* Location: ./system/core/Benchmark.php */
\ No newline at end of file
diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
index 349f9f2..c8245fc 100755
--- a/system/core/CodeIgniter.php
+++ b/system/core/CodeIgniter.php
@@ -31,7 +31,7 @@
  * Loads the base classes and executes the request.
  *
  * @package		CodeIgniter
- * @subpackage	codeigniter
+ * @subpackage	CodeIgniter
  * @category	Front-controller
  * @author		EllisLab Dev Team
  * @link		http://codeigniter.com/user_guide/
@@ -101,17 +101,6 @@
 
 /*
  * ------------------------------------------------------
- *  Set a liberal script execution time limit
- * ------------------------------------------------------
- */
-	if (function_exists('set_time_limit') && @ini_get('safe_mode') == 0
-		&& php_sapi_name() !== 'cli') // Do not override the Time Limit value if running from Command Line
-	{
-		@set_time_limit(300);
-	}
-
-/*
- * ------------------------------------------------------
  *  Start the timer... tick tock tick tock...
  * ------------------------------------------------------
  */
@@ -393,15 +382,5 @@
  */
 	$EXT->call_hook('post_system');
 
-/*
- * ------------------------------------------------------
- *  Close the DB connection if one exists
- * ------------------------------------------------------
- */
-	if (class_exists('CI_DB') && isset($CI->db) && ! $CI->db->pconnect)
-	{
-		$CI->db->close();
-	}
-
 /* End of file CodeIgniter.php */
 /* Location: ./system/core/CodeIgniter.php */
\ No newline at end of file
diff --git a/system/core/Common.php b/system/core/Common.php
index 78aa6e8..4b733ac 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -31,7 +31,7 @@
  * Loads the base classes and executes the request.
  *
  * @package		CodeIgniter
- * @subpackage	codeigniter
+ * @subpackage	CodeIgniter
  * @category	Common Functions
  * @author		EllisLab Dev Team
  * @link		http://codeigniter.com/user_guide/
@@ -57,7 +57,7 @@
 
 		if ( ! isset($_is_php[$version]))
 		{
-			$_is_php[$version] = (version_compare(PHP_VERSION, $version) < 0) ? FALSE : TRUE;
+			$_is_php[$version] = (version_compare(PHP_VERSION, $version) >= 0);
 		}
 
 		return $_is_php[$version];
@@ -487,16 +487,6 @@
 	 */
 	function _exception_handler($severity, $message, $filepath, $line)
 	{
-		 // We don't bother with "strict" notices since they tend to fill up
-		 // the log file with excess information that isn't normally very helpful.
-		 // For example, if you are running PHP 5 and you use version 4 style
-		 // class functions (without prefixes like "public", "private", etc.)
-		 // you'll get notices telling you that these have been deprecated.
-		if ($severity == E_STRICT)
-		{
-			return;
-		}
-
 		$_error =& load_class('Exceptions', 'core');
 
 		// Should we display the error? We'll get the current error_reporting
@@ -506,7 +496,7 @@
 			$_error->show_php_error($severity, $message, $filepath, $line);
 		}
 
-		// Should we log the error?  No?  We're done...
+		// Should we log the error? No? We're done...
 		if (config_item('log_threshold') == 0)
 		{
 			return;
diff --git a/system/core/Config.php b/system/core/Config.php
index 9cebe6c..c07ffa5 100755
--- a/system/core/Config.php
+++ b/system/core/Config.php
@@ -25,8 +25,6 @@
  * @filesource
  */
 
-// ------------------------------------------------------------------------
-
 /**
  * CodeIgniter Config Class
  *
@@ -46,14 +44,14 @@
 	 * @var array
 	 */
 	public $config =	array();
-	
+
 	/**
 	 * List of all loaded config files
 	 *
 	 * @var array
 	 */
 	public $is_loaded =	array();
-	
+
 	/**
 	 * List of paths to search when trying to load a config file.
 	 * This must be public as it's used by the Loader class.
@@ -77,9 +75,9 @@
 		{
 			if (isset($_SERVER['HTTP_HOST']))
 			{
-				$base_url = ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http';
-				$base_url .= '://'. $_SERVER['HTTP_HOST']
-					. str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
+				$base_url = ( ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') ? 'https' : 'http';
+				$base_url .= '://'.$_SERVER['HTTP_HOST']
+					.str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
 			}
 			else
 			{
@@ -96,9 +94,9 @@
 	 * Load Config File
 	 *
 	 * @param	string	the config file name
-	 * @param	boolean	if configuration values should be loaded into their own section
-	 * @param	boolean	true if errors should just return false, false if an error message should be displayed
-	 * @return	boolean	if the file was loaded correctly
+	 * @param	bool	if configuration values should be loaded into their own section
+	 * @param	bool	true if errors should just return false, false if an error message should be displayed
+	 * @return	bool	if the file was loaded correctly
 	 */
 	public function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
 	{
@@ -254,8 +252,8 @@
 	 * Base URL
 	 * Returns base_url [. uri_string]
 	 *
-	 * @param string $uri
-	 * @return string
+	 * @param	string	$uri
+	 * @return	string
 	 */
 	public function base_url($uri = '')
 	{
@@ -267,8 +265,8 @@
 	/**
 	 * Build URI string for use in Config::site_url() and Config::base_url()
 	 *
-	 * @param  mixed $uri
-	 * @return string
+	 * @param	mixed	$uri
+	 * @return	string
 	 */
 	protected function _uri_string($uri)
 	{
@@ -345,6 +343,7 @@
 			}
 		}
 	}
+
 }
 
 /* End of file Config.php */
diff --git a/system/core/Controller.php b/system/core/Controller.php
index 1f69146..4914148 100644
--- a/system/core/Controller.php
+++ b/system/core/Controller.php
@@ -48,6 +48,8 @@
 
 	/**
 	 * Set up controller properties and methods
+	 *
+	 * @return	void
 	 */
 	public function __construct()
 	{
@@ -67,14 +69,15 @@
 	}
 
 	/**
-	 * Return the CI object 
+	 * Return the CI object
 	 *
-	 * @return object
+	 * @return	object
 	 */
 	public static function &get_instance()
 	{
 		return self::$instance;
 	}
+
 }
 
 /* End of file Controller.php */
diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php
index 2e9f0c7..8c32085 100755
--- a/system/core/Exceptions.php
+++ b/system/core/Exceptions.php
@@ -65,6 +65,8 @@
 
 	/**
 	 * Initialize execption class
+	 *
+	 * @return	void
 	 */
 	public function __construct()
 	{
@@ -87,7 +89,7 @@
 	 */
 	public function log_exception($severity, $message, $filepath, $line)
 	{
-		$severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
+		$severity = isset($this->levels[$severity]) ? $this->levels[$severity] : $severity;
 		log_message('error', 'Severity: '.$severity.'  --> '.$message. ' '.$filepath.' '.$line, TRUE);
 	}
 
@@ -127,21 +129,21 @@
 	 * @param	string	the heading
 	 * @param	string	the message
 	 * @param	string	the template name
-	 * @param 	int		the status code
+	 * @param 	int	the status code
 	 * @return	string
 	 */
 	public function show_error($heading, $message, $template = 'error_general', $status_code = 500)
 	{
 		set_status_header($status_code);
 
-		$message = '<p>'.implode('</p><p>', ( ! is_array($message)) ? array($message) : $message).'</p>';
+		$message = '<p>'.implode('</p><p>', is_array($message) ? $message : array($message)).'</p>';
 
 		if (ob_get_level() > $this->ob_level + 1)
 		{
 			ob_end_flush();
 		}
 		ob_start();
-		include(APPPATH.'errors/'.$template.'.php');
+		include(APPPATH.'views/errors/'.$template.'.php');
 		$buffer = ob_get_contents();
 		ob_end_clean();
 		return $buffer;
@@ -160,7 +162,7 @@
 	 */
 	public function show_php_error($severity, $message, $filepath, $line)
 	{
-		$severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
+		$severity = isset($this->levels[$severity]) ? $this->levels[$severity] : $severity;
 		$filepath = str_replace('\\', '/', $filepath);
 
 		// For safety reasons we do not show the full file path
@@ -175,7 +177,7 @@
 			ob_end_flush();
 		}
 		ob_start();
-		include(APPPATH.'errors/'.'error_php.php');
+		include(APPPATH.'views/errors/error_php.php');
 		$buffer = ob_get_contents();
 		ob_end_clean();
 		echo $buffer;
diff --git a/system/core/Hooks.php b/system/core/Hooks.php
index b42ecbe..5bbb000 100755
--- a/system/core/Hooks.php
+++ b/system/core/Hooks.php
@@ -44,14 +44,14 @@
 	 * @var bool
 	 */
 	public $enabled =	FALSE;
-	
+
 	/**
 	 * List of all hooks set in config/hooks.php
 	 *
 	 * @var array
 	 */
 	public $hooks =	array();
-	
+
 	/**
 	 * Determines wether hook is in progress, used to prevent infinte loops
 	 *
@@ -152,7 +152,7 @@
 
 		// If the script being called happens to have the same
 		// hook call within it a loop can happen
-		if ($this->in_progress == TRUE)
+		if ($this->in_progress === TRUE)
 		{
 			return;
 		}
diff --git a/system/core/Input.php b/system/core/Input.php
index fc2a550..e916ac6 100755
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -44,28 +44,28 @@
 	 * @var string
 	 */
 	public $ip_address =	FALSE;
-	
+
 	/**
 	 * user agent (web browser) being used by the current user
 	 *
 	 * @var string
 	 */
 	public $user_agent =	FALSE;
-	
+
 	/**
 	 * If FALSE, then $_GET will be set to an empty array
 	 *
 	 * @var bool
 	 */
 	protected $_allow_get_array =	TRUE;
-	
+
 	/**
 	 * If TRUE, then newlines are standardized
 	 *
 	 * @var bool
 	 */
 	protected $_standardize_newlines =	TRUE;
-	
+
 	/**
 	 * Determines whether the XSS filter is always active when GET, POST or COOKIE data is encountered
 	 * Set automatically based on config setting
@@ -73,7 +73,7 @@
 	 * @var bool
 	 */
 	protected $_enable_xss =	FALSE;
-	
+
 	/**
 	 * Enables a CSRF cookie token to be set.
 	 * Set automatically based on config setting
@@ -81,7 +81,7 @@
 	 * @var bool
 	 */
 	protected $_enable_csrf =	FALSE;
-	
+
 	/**
 	 * List of all HTTP request headers
 	 *
@@ -94,6 +94,8 @@
 	 *
 	 * Sets whether to globally enable the XSS processing
 	 * and whether to allow the $_GET array
+	 *
+	 * @return	void
 	 */
 	public function __construct()
 	{
@@ -438,15 +440,7 @@
 		// This is effectively the same as register_globals = off
 		foreach (array($_GET, $_POST, $_COOKIE) as $global)
 		{
-			if ( ! is_array($global))
-			{
-				if ( ! in_array($global, $protected))
-				{
-					global $$global;
-					$$global = NULL;
-				}
-			}
-			else
+			if (is_array($global))
 			{
 				foreach ($global as $key => $val)
 				{
@@ -457,6 +451,11 @@
 					}
 				}
 			}
+			elseif ( ! in_array($global, $protected))
+			{
+				global $$global;
+				$$global = NULL;
+			}
 		}
 
 		// Is $_GET data allowed? If not we'll set the $_GET to an empty array
@@ -605,7 +604,7 @@
 	 * In Apache, you can simply call apache_request_headers(), however for
 	 * people running other webservers the function is undefined.
 	 *
-	 * @param	bool XSS cleaning
+	 * @param	bool	XSS cleaning
 	 * @return	array
 	 */
 	public function request_headers($xss_clean = FALSE)
diff --git a/system/core/Loader.php b/system/core/Loader.php
index bf7f6cb..3eb09e6 100644
--- a/system/core/Loader.php
+++ b/system/core/Loader.php
@@ -32,8 +32,8 @@
  *
  * @package		CodeIgniter
  * @subpackage	Libraries
- * @author		EllisLab Dev Team
  * @category	Loader
+ * @author		EllisLab Dev Team
  * @link		http://codeigniter.com/user_guide/libraries/loader.html
  */
 class CI_Loader {
@@ -45,77 +45,77 @@
 	 * @var int
 	 */
 	protected $_ci_ob_level;
-	
+
 	/**
 	 * List of paths to load views from
 	 *
 	 * @var array
 	 */
 	protected $_ci_view_paths =	array();
-	
+
 	/**
 	 * List of paths to load libraries from
 	 *
 	 * @var array
 	 */
 	protected $_ci_library_paths =	array();
-	
+
 	/**
 	 * List of paths to load models from
 	 *
 	 * @var array
 	 */
 	protected $_ci_model_paths =	array();
-	
+
 	/**
 	 * List of paths to load helpers from
 	 *
 	 * @var array
 	 */
 	protected $_ci_helper_paths =	array();
-	
+
 	/**
 	 * List of loaded base classes
 	 *
 	 * @var array
 	 */
 	protected $_base_classes =	array(); // Set by the controller class
-	
+
 	/**
 	 * List of cached variables
 	 *
 	 * @var array
 	 */
 	protected $_ci_cached_vars =	array();
-	
+
 	/**
 	 * List of loaded classes
 	 *
 	 * @var array
 	 */
 	protected $_ci_classes =	array();
-	
+
 	/**
 	 * List of loaded files
 	 *
 	 * @var array
 	 */
 	protected $_ci_loaded_files =	array();
-	
+
 	/**
 	 * List of loaded models
 	 *
 	 * @var array
 	 */
 	protected $_ci_models =	array();
-	
+
 	/**
 	 * List of loaded helpers
 	 *
 	 * @var array
 	 */
 	protected $_ci_helpers =	array();
-	
+
 	/**
 	 * List of class name mappings
 	 *
@@ -130,6 +130,8 @@
 	 * Constructor
 	 *
 	 * Sets the path to the view files and gets the initial output buffering level
+	 *
+	 * @return	void
 	 */
 	public function __construct()
 	{
@@ -178,12 +180,7 @@
 	 */
 	public function is_loaded($class)
 	{
-		if (isset($this->_ci_classes[$class]))
-		{
-			return $this->_ci_classes[$class];
-		}
-
-		return FALSE;
+		return isset($this->_ci_classes[$class]) ? $this->_ci_classes[$class] : FALSE;
 	}
 
 	// --------------------------------------------------------------------
@@ -1263,4 +1260,4 @@
 }
 
 /* End of file Loader.php */
-/* Location: ./system/core/Loader.php */
+/* Location: ./system/core/Loader.php */
\ No newline at end of file
diff --git a/system/core/Model.php b/system/core/Model.php
index 7c99719..9bc9f87 100755
--- a/system/core/Model.php
+++ b/system/core/Model.php
@@ -38,6 +38,8 @@
 
 	/**
 	 * Initialize CI_Model Class
+	 *
+	 * @return	void
 	 */
 	public function __construct()
 	{
@@ -57,6 +59,7 @@
 		$CI =& get_instance();
 		return $CI->$key;
 	}
+
 }
 
 /* End of file Model.php */
diff --git a/system/core/Output.php b/system/core/Output.php
index 513c657..c8feb4e 100755
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -44,49 +44,49 @@
 	 * @var string
 	 */
 	public $final_output;
-	
+
 	/**
 	 * Cache expiration time
 	 *
 	 * @var int
 	 */
 	public $cache_expiration =	0;
-	
+
 	/**
 	 * List of server headers
 	 *
 	 * @var array
 	 */
 	public $headers =	array();
-	
+
 	/**
 	 * List of mime types
 	 *
 	 * @var array
 	 */
 	public $mime_types =	array();
-	
+
 	/**
 	 * Determines wether profiler is enabled
 	 *
 	 * @var book
 	 */
 	public $enable_profiler =	FALSE;
-	
+
 	/**
 	 * Determines if output compression is enabled
 	 *
 	 * @var bool
 	 */
 	protected $_zlib_oc =	FALSE;
-	
+
 	/**
 	 * List of profiler sections
 	 *
 	 * @var array
 	 */
 	protected $_profiler_sections =	array();
-	
+
 	/**
 	 * Whether or not to parse variables like {elapsed_time} and {memory_usage}
 	 *
@@ -96,6 +96,8 @@
 
 	/**
 	 * Set up Output class
+	 *
+	 * @return	void
 	 */
 	public function __construct()
 	{
@@ -177,7 +179,7 @@
 	 *
 	 * Lets you set a server header which will be outputted with the final display.
 	 *
-	 * Note:  If a file is cached, headers will not be sent.  We need to figure out
+	 * Note: If a file is cached, headers will not be sent. We need to figure out
 	 * how to permit header data to be saved with the cache data...
 	 *
 	 * @param	string
diff --git a/system/core/Router.php b/system/core/Router.php
index 9314052..5ea1379 100755
--- a/system/core/Router.php
+++ b/system/core/Router.php
@@ -32,8 +32,8 @@
  *
  * @package		CodeIgniter
  * @subpackage	Libraries
- * @author		EllisLab Dev Team
  * @category	Libraries
+ * @author		EllisLab Dev Team
  * @link		http://codeigniter.com/user_guide/general/routing.html
  */
 class CI_Router {
@@ -44,42 +44,42 @@
 	 * @var object
 	 */
 	public $config;
-	
+
 	/**
 	 * List of routes
 	 *
 	 * @var array
 	 */
 	public $routes =	array();
-	
+
 	/**
 	 * List of error routes
 	 *
 	 * @var array
 	 */
 	public $error_routes =	array();
-	
+
 	/**
 	 * Current class name
 	 *
 	 * @var string
 	 */
-	public $class =	'';
-	
+	public $class =		'';
+
 	/**
 	 * Current method name
 	 *
 	 * @var string
 	 */
 	public $method =	'index';
-	
+
 	/**
 	 * Sub-directory that contains the requested controller class
 	 *
 	 * @var string
 	 */
 	public $directory =	'';
-	
+
 	/**
 	 * Default controller (and method if specific)
 	 *
@@ -91,6 +91,8 @@
 	 * Constructor
 	 *
 	 * Runs the route mapping function.
+	 *
+	 * @return	void
 	 */
 	public function __construct()
 	{
@@ -433,12 +435,7 @@
 	 */
 	public function fetch_method()
 	{
-		if ($this->method == $this->fetch_class())
-		{
-			return 'index';
-		}
-
-		return $this->method;
+		return ($this->method == $this->fetch_class()) ? 'index' : $this->method;
 	}
 
 	// --------------------------------------------------------------------
diff --git a/system/core/Security.php b/system/core/Security.php
index 974e2e4..f953011 100755
--- a/system/core/Security.php
+++ b/system/core/Security.php
@@ -95,15 +95,18 @@
 	 *
 	 * @var array
 	 */
-	protected $_never_allowed_regex =	array(
+	protected $_never_allowed_regex = array(
 		'javascript\s*:',
 		'expression\s*(\(|&\#40;)', // CSS and IE
 		'vbscript\s*:', // IE, surprise!
-		'Redirect\s+302'
+		'Redirect\s+302',
+		"([\"'])?data\s*:[^\\1]*?base64[^\\1]*?,[^\\1]*?\\1?"
 	);
 
 	/**
 	 * Initialize security class
+	 *
+	 * @return	void
 	 */
 	public function __construct()
 	{
@@ -200,11 +203,11 @@
 		}
 
 		setcookie(
-			$this->_csrf_cookie_name, 
-			$this->_csrf_hash, 
-			$expire, 
-			config_item('cookie_path'), 
-			config_item('cookie_domain'), 
+			$this->_csrf_cookie_name,
+			$this->_csrf_hash,
+			$expire,
+			config_item('cookie_path'),
+			config_item('cookie_domain'),
 			$secure_cookie,
 			config_item('cookie_httponly')
 		);
@@ -365,10 +368,11 @@
 		 * These words are compacted back to their correct state.
 		 */
 		$words = array(
-			'javascript', 'expression', 'vbscript', 'script',
+			'javascript', 'expression', 'vbscript', 'script', 'base64',
 			'applet', 'alert', 'document', 'write', 'cookie', 'window'
 		);
 
+
 		foreach ($words as $word)
 		{
 			$word = implode('\s*', str_split($word)).'\s*';
@@ -605,10 +609,11 @@
 			$attribs = array();
 
 			// find occurrences of illegal attribute strings without quotes
-			preg_match_all('/('.implode('|', $evil_attributes).')\s*=\s*([^\s]*)/is', $str, $matches, PREG_SET_ORDER);
+			preg_match_all('/('.implode('|', $evil_attributes).')\s*=\s*([^\s>]*)/is', $str, $matches, PREG_SET_ORDER);
 
 			foreach ($matches as $attr)
 			{
+
 				$attribs[] = preg_quote($attr[0], '/');
 			}
 
@@ -623,7 +628,7 @@
 			// replace illegal attribute strings that are inside an html tag
 			if (count($attribs) > 0)
 			{
-				$str = preg_replace('/<(\/?[^><]+?)([^A-Za-z\-])('.implode('|', $attribs).')([\s><])([><]*)/i', '<$1$2$4$5', $str, -1, $count);
+				$str = preg_replace('/<(\/?[^><]+?)([^A-Za-z<>\-])(.*?)('.implode('|', $attribs).')(.*?)([\s><])([><]*)/i', '<$1 $3$5$6$7', $str, -1, $count);
 			}
 
 		} while ($count);
@@ -664,7 +669,7 @@
 	protected function _js_link_removal($match)
 	{
 		return str_replace($match[1],
-					preg_replace('#href=.*?(alert\(|alert&\#40;|javascript\:|livescript\:|mocha\:|charset\=|window\.|document\.|\.cookie|<script|<xss|base64\s*,)#si',
+					preg_replace('#href=.*?(alert\(|alert&\#40;|javascript\:|livescript\:|mocha\:|charset\=|window\.|document\.|\.cookie|<script|<xss|data\s*:)#si',
 							'',
 							$this->_filter_attributes(str_replace(array('<', '>'), '', $match[1]))
 					),
@@ -804,7 +809,7 @@
 
 		foreach ($this->_never_allowed_regex as $regex)
 		{
-			$str = preg_replace('#'.$regex.'#i', '[removed]', $str);
+			$str = preg_replace('#'.$regex.'#is', '[removed]', $str);
 		}
 
 		return $str;
@@ -826,7 +831,7 @@
 			// each page load since a page could contain embedded
 			// sub-pages causing this feature to fail
 			if (isset($_COOKIE[$this->_csrf_cookie_name]) &&
-				$_COOKIE[$this->_csrf_cookie_name] != '')
+				preg_match('#^[0-9a-f]{32}$#iS', $_COOKIE[$this->_csrf_cookie_name]) === 1)
 			{
 				return $this->_csrf_hash = $_COOKIE[$this->_csrf_cookie_name];
 			}
@@ -841,4 +846,4 @@
 }
 
 /* End of file Security.php */
-/* Location: ./system/core/Security.php */
\ No newline at end of file
+/* Location: ./system/core/Security.php */
diff --git a/system/core/URI.php b/system/core/URI.php
index cf82c58..e66cb6d 100755
--- a/system/core/URI.php
+++ b/system/core/URI.php
@@ -22,6 +22,7 @@
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 1.0
+ * @filesource
  */
 
 /**
@@ -43,21 +44,21 @@
 	 * @var array
 	 */
 	public $keyval =	array();
-	
+
 	/**
 	 * Current uri string
 	 *
 	 * @var string
 	 */
 	public $uri_string;
-	
+
 	/**
 	 * List of uri segments
 	 *
 	 * @var array
 	 */
 	public $segments =	array();
-	
+
 	/**
 	 * Re-indexed list of uri segments
 	 * Starts at 1 instead of 0
@@ -72,6 +73,8 @@
 	 * Simply globalizes the $RTR object. The front
 	 * loads the Router class early on so it's not available
 	 * normally as other classes are.
+	 *
+	 * @return	void
 	 */
 	public function __construct()
 	{
@@ -148,7 +151,7 @@
 			return;
 		}
 
-		$path = (isset($_SERVER[$uri])) ? $_SERVER[$uri] : @getenv($uri);
+		$path = isset($_SERVER[$uri]) ? $_SERVER[$uri] : @getenv($uri);
 		$this->_set_uri_string($path);
 	}
 
@@ -181,7 +184,7 @@
 	 */
 	protected function _detect_uri()
 	{
-		if ( ! isset($_SERVER['REQUEST_URI']) OR ! isset($_SERVER['SCRIPT_NAME']))
+		if ( ! isset($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME']))
 		{
 			return '';
 		}
@@ -227,20 +230,19 @@
 	}
 
 	// --------------------------------------------------------------------
-	
+
 	/**
 	 * Is cli Request?
 	 *
 	 * Duplicate of function from the Input class to test to see if a request was made from the command line
 	 *
-	 * @return 	boolean
+	 * @return 	bool
 	 */
 	protected function _is_cli_request()
 	{
-		return (php_sapi_name() == 'cli') OR defined('STDIN');
+		return (php_sapi_name() === 'cli') OR defined('STDIN');
 	}
 
-	
 	// --------------------------------------------------------------------
 
 	/**
@@ -253,7 +255,7 @@
 	protected function _parse_cli_args()
 	{
 		$args = array_slice($_SERVER['argv'], 1);
-		return $args ? '/' . implode('/', $args) : '';
+		return $args ? '/'.implode('/', $args) : '';
 	}
 
 	// --------------------------------------------------------------------
@@ -327,7 +329,7 @@
 	}
 
 	// --------------------------------------------------------------------
-	
+
 	/**
 	 * Re-index Segments
 	 *
@@ -355,13 +357,13 @@
 	 *
 	 * This function returns the URI segment based on the number provided.
 	 *
-	 * @param	integer
+	 * @param	int
 	 * @param	bool
 	 * @return	string
 	 */
 	public function segment($n, $no_result = FALSE)
 	{
-		return ( ! isset($this->segments[$n])) ? $no_result : $this->segments[$n];
+		return isset($this->segments[$n]) ? $this->segments[$n] : $no_result;
 	}
 
 	// --------------------------------------------------------------------
@@ -370,16 +372,16 @@
 	 * Fetch a URI "routed" Segment
 	 *
 	 * This function returns the re-routed URI segment (assuming routing rules are used)
-	 * based on the number provided.  If there is no routing this function returns the
+	 * based on the number provided. If there is no routing this function returns the
 	 * same result as $this->segment()
 	 *
-	 * @param	integer
+	 * @param	int
 	 * @param	bool
 	 * @return	string
 	 */
 	public function rsegment($n, $no_result = FALSE)
 	{
-		return ( ! isset($this->rsegments[$n])) ? $no_result : $this->rsegments[$n];
+		return isset($this->rsegments[$n]) ? $this->rsegments[$n] : $no_result;
 	}
 
 	// --------------------------------------------------------------------
@@ -400,7 +402,7 @@
 	 *			gender => male
 	 *		 )
 	 *
-	 * @param	integer	the starting segment number
+	 * @param	int	the starting segment number
 	 * @param	array	an array of default values
 	 * @return	array
 	 */
@@ -408,13 +410,13 @@
 	{
 		return $this->_uri_to_assoc($n, $default, 'segment');
 	}
-	
+
 	// --------------------------------------------------------------------
-	
+
 	/**
 	 * Identical to above only it uses the re-routed segment array
 	 *
-	 * @param 	integer	the starting segment number
+	 * @param 	int	the starting segment number
 	 * @param 	array	an array of default values
 	 * @return 	array
 	 */
@@ -428,7 +430,7 @@
 	/**
 	 * Generate a key value pair from the URI string or Re-routed URI string
 	 *
-	 * @param	integer	the starting segment number
+	 * @param	int	the starting segment number
 	 * @param	array	an array of default values
 	 * @param	string	which array we should use
 	 * @return	array
@@ -458,12 +460,9 @@
 
 		if ($this->$total_segments() < $n)
 		{
-			if (count($default) === 0)
-			{
-				return array();
-			}
-
-			return array_fill_keys($default, FALSE);
+			return (count($default) === 0)
+				? array()
+				: array_fill_keys($default, FALSE);
 		}
 
 		$segments = array_slice($this->$segment_array(), ($n - 1));
@@ -512,7 +511,7 @@
 	public function assoc_to_uri($array)
 	{
 		$temp = array();
-		foreach ((array)$array as $key => $val)
+		foreach ( (array) $array as $key => $val)
 		{
 			$temp[] = $key;
 			$temp[] = $val;
@@ -526,7 +525,7 @@
 	/**
 	 * Fetch a URI Segment and add a trailing slash
 	 *
-	 * @param	integer
+	 * @param	int
 	 * @param	string
 	 * @return	string
 	 */
@@ -540,7 +539,7 @@
 	/**
 	 * Fetch a URI Segment and add a trailing slash
 	 *
-	 * @param	integer
+	 * @param	int
 	 * @param	string
 	 * @return	string
 	 */
@@ -554,7 +553,7 @@
 	/**
 	 * Fetch a URI Segment and add a trailing slash - helper function
 	 *
-	 * @param	integer
+	 * @param	int
 	 * @param	string
 	 * @param	string
 	 * @return	string
@@ -604,7 +603,7 @@
 	/**
 	 * Total number of segments
 	 *
-	 * @return	integer
+	 * @return	int
 	 */
 	public function total_segments()
 	{
@@ -616,7 +615,7 @@
 	/**
 	 * Total number of routed segments
 	 *
-	 * @return	integer
+	 * @return	int
 	 */
 	public function total_rsegments()
 	{
@@ -651,4 +650,4 @@
 }
 
 /* End of file URI.php */
-/* Location: ./system/core/URI.php */
+/* Location: ./system/core/URI.php */
\ No newline at end of file
diff --git a/system/core/Utf8.php b/system/core/Utf8.php
index 122020a..a6faa84 100644
--- a/system/core/Utf8.php
+++ b/system/core/Utf8.php
@@ -42,6 +42,8 @@
 	 * Constructor
 	 *
 	 * Determines if UTF-8 support is to be enabled
+	 *
+	 * @return	void
 	 */
 	public function __construct()
 	{
@@ -124,7 +126,7 @@
 	 * Attempts to convert a string to UTF-8
 	 *
 	 * @param	string
-	 * @param	string	- input encoding
+	 * @param	string	input encoding
 	 * @return	string
 	 */
 	public function convert_to_utf8($str, $encoding)
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index ef77b59..a0812d4 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -1152,7 +1152,7 @@
 	{
 		if ($this->conn_id)
 		{
-			$this->_close($this->conn_id);
+			$this->_close();
 			$this->conn_id = FALSE;
 		}
 	}
@@ -1160,6 +1160,20 @@
 	// --------------------------------------------------------------------
 
 	/**
+	 * Close DB Connection
+	 *
+	 * This method would be overriden by most of the drivers.
+	 *
+	 * @return	void
+	 */
+	protected function _close()
+	{
+		$this->conn_id = FALSE;
+	}
+
+	// --------------------------------------------------------------------
+
+	/**
 	 * Display an error message
 	 *
 	 * @param	string	the error message
@@ -1390,7 +1404,24 @@
 	{
 	}
 
+	// --------------------------------------------------------------------
+
+	/**
+	 * Destructor
+	 *
+	 * Closes the database connection, if needed.
+	 *
+	 * @return	void
+	 */
+	public function __destruct()
+	{
+		if ( ! $this->pconnect)
+		{
+			$this->close();
+		}
+	}
+
 }
 
 /* End of file DB_driver.php */
-/* Location: ./system/database/DB_driver.php */
+/* Location: ./system/database/DB_driver.php */
\ No newline at end of file
diff --git a/system/database/DB_result.php b/system/database/DB_result.php
index 196febe..690734b 100644
--- a/system/database/DB_result.php
+++ b/system/database/DB_result.php
@@ -371,6 +371,18 @@
 	// --------------------------------------------------------------------
 
 	/**
+	 * Returns an unbuffered row and move pointer to next row
+	 *
+	 * @return	mixed	either a result object or array
+	 */
+	public function unbuffered_row($type = 'object')
+	{
+		return ($type !== 'array') ? $this->_fetch_object() : $this->_fetch_assoc();
+	}
+
+	// --------------------------------------------------------------------
+
+	/**
 	 * The following functions are normally overloaded by the identically named
 	 * methods in the platform-specific driver -- except when query caching
 	 * is used. When caching is enabled we do not load the other driver.
diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php
index 1373faa..944df99 100644
--- a/system/database/drivers/cubrid/cubrid_driver.php
+++ b/system/database/drivers/cubrid/cubrid_driver.php
@@ -485,7 +485,7 @@
 	}
 
 	// --------------------------------------------------------------------
-	
+
 	/**
 	 * Limit string
 	 *
@@ -506,15 +506,14 @@
 	/**
 	 * Close DB Connection
 	 *
-	 * @param	resource
 	 * @return	void
 	 */
-	protected function _close($conn_id)
+	protected function _close()
 	{
-		@cubrid_close($conn_id);
+		@cubrid_close($this->conn_id);
 	}
 
 }
 
 /* End of file cubrid_driver.php */
-/* Location: ./system/database/drivers/cubrid/cubrid_driver.php */
+/* Location: ./system/database/drivers/cubrid/cubrid_driver.php */
\ No newline at end of file
diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php
index 1b18de8..c457f63 100644
--- a/system/database/drivers/interbase/interbase_driver.php
+++ b/system/database/drivers/interbase/interbase_driver.php
@@ -472,12 +472,11 @@
 	/**
 	 * Close DB Connection
 	 *
-	 * @param	resource
 	 * @return	void
 	 */
-	protected function _close($conn_id)
+	protected function _close()
 	{
-		@ibase_close($conn_id);
+		@ibase_close($this->conn_id);
 	}
 
 }
diff --git a/system/database/drivers/interbase/interbase_utility.php b/system/database/drivers/interbase/interbase_utility.php
index 1b92af9..1642118 100644
--- a/system/database/drivers/interbase/interbase_utility.php
+++ b/system/database/drivers/interbase/interbase_utility.php
@@ -42,7 +42,7 @@
 	 * @param	string	$filename
 	 * @return	mixed
 	 */
-	protected function backup($filename)
+	protected function _backup($filename)
 	{
 		if ($service = ibase_service_attach($this->db->hostname, $this->db->username, $this->db->password))
 		{
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index f60ec81..914de49 100644
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -523,15 +523,14 @@
 	/**
 	 * Close DB Connection
 	 *
-	 * @param	resource
 	 * @return	void
 	 */
-	protected function _close($conn_id)
+	protected function _close()
 	{
-		@mssql_close($conn_id);
+		@mssql_close($this->conn_id);
 	}
 
 }
 
 /* End of file mssql_driver.php */
-/* Location: ./system/database/drivers/mssql/mssql_driver.php */
+/* Location: ./system/database/drivers/mssql/mssql_driver.php */
\ No newline at end of file
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
index 32c5186..161f995 100644
--- a/system/database/drivers/mysql/mysql_driver.php
+++ b/system/database/drivers/mysql/mysql_driver.php
@@ -520,15 +520,14 @@
 	/**
 	 * Close DB Connection
 	 *
-	 * @param	resource
 	 * @return	void
 	 */
-	protected function _close($conn_id)
+	protected function _close()
 	{
-		@mysql_close($conn_id);
+		@mysql_close($this->conn_id);
 	}
 
 }
 
 /* End of file mysql_driver.php */
-/* Location: ./system/database/drivers/mysql/mysql_driver.php */
+/* Location: ./system/database/drivers/mysql/mysql_driver.php */
\ No newline at end of file
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index e2684e4..9261883 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -523,16 +523,14 @@
 	/**
 	 * Close DB Connection
 	 *
-	 * @param	object
 	 * @return	void
 	 */
-	protected function _close($conn_id)
+	protected function _close()
 	{
 		$this->conn_id->close();
-		$this->conn_id = FALSE;
 	}
 
 }
 
 /* End of file mysqli_driver.php */
-/* Location: ./system/database/drivers/mysqli/mysqli_driver.php */
+/* Location: ./system/database/drivers/mysqli/mysqli_driver.php */
\ No newline at end of file
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index 33a89df..e2fa513 100644
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -671,15 +671,14 @@
 	/**
 	 * Close DB Connection
 	 *
-	 * @param	resource
 	 * @return	void
 	 */
-	protected function _close($conn_id)
+	protected function _close()
 	{
-		@oci_close($conn_id);
+		@oci_close($this->conn_id);
 	}
 
 }
 
 /* End of file oci8_driver.php */
-/* Location: ./system/database/drivers/oci8/oci8_driver.php */
+/* Location: ./system/database/drivers/oci8/oci8_driver.php */
\ No newline at end of file
diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
index e36f2d2..e317211 100644
--- a/system/database/drivers/odbc/odbc_driver.php
+++ b/system/database/drivers/odbc/odbc_driver.php
@@ -402,15 +402,14 @@
 	/**
 	 * Close DB Connection
 	 *
-	 * @param	resource
 	 * @return	void
 	 */
-	protected function _close($conn_id)
+	protected function _close()
 	{
-		@odbc_close($conn_id);
+		@odbc_close($this->conn_id);
 	}
 
 }
 
 /* End of file odbc_driver.php */
-/* Location: ./system/database/drivers/odbc/odbc_driver.php */
+/* Location: ./system/database/drivers/odbc/odbc_driver.php */
\ No newline at end of file
diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php
index 89e6967..e38c114 100644
--- a/system/database/drivers/pdo/pdo_driver.php
+++ b/system/database/drivers/pdo/pdo_driver.php
@@ -667,20 +667,7 @@
 		}
 	}
 
-	// --------------------------------------------------------------------
-
-	/**
-	 * Close DB Connection
-	 *
-	 * @param	object
-	 * @return	void
-	 */
-	protected function _close($conn_id)
-	{
-		$this->conn_id = NULL;
-	}
-
 }
 
 /* End of file pdo_driver.php */
-/* Location: ./system/database/drivers/pdo/pdo_driver.php */
+/* Location: ./system/database/drivers/pdo/pdo_driver.php */
\ No newline at end of file
diff --git a/system/database/drivers/pdo/pdo_result.php b/system/database/drivers/pdo/pdo_result.php
index 19aee1d..0b8937c 100644
--- a/system/database/drivers/pdo/pdo_result.php
+++ b/system/database/drivers/pdo/pdo_result.php
@@ -84,19 +84,14 @@
 		// Define the output
 		$output = array('assoc', 'object');
 
+		// Initial value
+		$this->result_assoc = array() and $this->result_object = array();
+
 		// Fetch the result
-		foreach ($output as $type)
+		while ($row = $this->_fetch_assoc())
 		{
-			// Define the method and handler
-			$res_method  = '_fetch_'.$type;
-			$res_handler = 'result_'.$type;
-
-			$this->$res_handler = array();
-
-			while ($row = $this->$res_method())
-			{
-				$this->{$res_handler}[] = $row;
-			}
+			$this->result_assoc[] = $row;
+			$this->result_object[] = (object) $row;
 		}
 
 		// Save this as buffer and marked the fetch flag
@@ -249,7 +244,7 @@
 	 */
 	protected function _fetch_object()
 	{
-		return $this->result_id->fetchObject();
+		return $this->result_id->fetch(PDO::FETCH_OBJ);
 	}
 
 }
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 84bf768..0ddfd0a 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -311,6 +311,27 @@
 	// --------------------------------------------------------------------
 
 	/**
+	 * "Smart" Escape String
+	 *
+	 * Escapes data based on type
+	 * Sets boolean and null types
+	 *
+	 * @param	string
+	 * @return	mixed
+	 */
+	public function escape($str)
+	{
+		if (is_bool($str))
+		{
+			return ($str) ? 'TRUE' : 'FALSE';
+		}
+
+		return parent::escape($str);
+	}
+
+	// --------------------------------------------------------------------
+
+	/**
 	 * Affected Rows
 	 *
 	 * @return	int
@@ -558,17 +579,88 @@
 	// --------------------------------------------------------------------
 
 	/**
+	 * Where
+	 *
+	 * Called by where() or or_where()
+	 *
+	 * @param	mixed
+	 * @param	mixed
+	 * @param	string
+	 * @return	object
+	 *
+	 */
+	protected function _where($key, $value = NULL, $type = 'AND ', $escape = NULL)
+	{
+		$type = $this->_group_get_type($type);
+
+		if ( ! is_array($key))
+		{
+			$key = array($key => $value);
+		}
+
+		// If the escape value was not set will will base it on the global setting
+		if ( ! is_bool($escape))
+		{
+			$escape = $this->_protect_identifiers;
+		}
+
+		foreach ($key as $k => $v)
+		{
+			$prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) ? '' : $type;
+
+			if (is_null($v) && ! $this->_has_operator($k))
+			{
+				// value appears not to have been set, assign the test to IS NULL
+				$k .= ' IS NULL';
+			}
+
+			if ( ! is_null($v))
+			{
+				if ($escape === TRUE)
+				{
+					$k = $this->protect_identifiers($k, FALSE, $escape);
+					$v = ' '.$this->escape($v);
+				}
+				elseif (is_bool($v))
+				{
+					$v = ($v ? ' TRUE' : ' FALSE');
+				}
+
+				if ( ! $this->_has_operator($k))
+				{
+					$k .= ' = ';
+				}
+			}
+			else
+			{
+				$k = $this->protect_identifiers($k, FALSE, $escape);
+			}
+
+			$this->qb_where[] = $prefix.$k.$v;
+			if ($this->qb_caching === TRUE)
+			{
+				$this->qb_cache_where[] = $prefix.$k.$v;
+				$this->qb_cache_exists[] = 'where';
+			}
+
+		}
+
+		return $this;
+	}
+
+	// --------------------------------------------------------------------
+
+	/**
 	 * Close DB Connection
 	 *
-	 * @param	resource
 	 * @return	void
 	 */
-	protected function _close($conn_id)
+	protected function _close()
 	{
-		@pg_close($conn_id);
+		@pg_close($this->conn_id);
 	}
 
 }
 
 /* End of file postgre_driver.php */
-/* Location: ./system/database/drivers/postgre/postgre_driver.php */
+/* Location: ./system/database/drivers/postgre/postgre_driver.php */
\ No newline at end of file
diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php
index 551704f..d710b94 100644
--- a/system/database/drivers/sqlite/sqlite_driver.php
+++ b/system/database/drivers/sqlite/sqlite_driver.php
@@ -450,15 +450,14 @@
 	/**
 	 * Close DB Connection
 	 *
-	 * @param	resource
 	 * @return	void
 	 */
-	protected function _close($conn_id)
+	protected function _close()
 	{
-		@sqlite_close($conn_id);
+		@sqlite_close($this->conn_id);
 	}
 
 }
 
 /* End of file sqlite_driver.php */
-/* Location: ./system/database/drivers/sqlite/sqlite_driver.php */
+/* Location: ./system/database/drivers/sqlite/sqlite_driver.php */
\ No newline at end of file
diff --git a/system/database/drivers/sqlite3/sqlite3_driver.php b/system/database/drivers/sqlite3/sqlite3_driver.php
index d22f6a4..ad2848e 100644
--- a/system/database/drivers/sqlite3/sqlite3_driver.php
+++ b/system/database/drivers/sqlite3/sqlite3_driver.php
@@ -417,10 +417,9 @@
 	/**
 	 * Close DB Connection
 	 *
-	 * @param	object (ignored)
 	 * @return	void
 	 */
-	protected function _close($conn_id)
+	protected function _close()
 	{
 		$this->conn_id->close();
 	}
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
index 8cc500f..3e9fa7b 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_driver.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -510,15 +510,14 @@
 	/**
 	 * Close DB Connection
 	 *
-	 * @param	resource
 	 * @return	void
 	 */
-	protected function _close($conn_id)
+	protected function _close()
 	{
-		@sqlsrv_close($conn_id);
+		@sqlsrv_close($this->conn_id);
 	}
 
 }
 
 /* End of file sqlsrv_driver.php */
-/* Location: ./system/database/drivers/sqlsrv/sqlsrv_driver.php */
+/* Location: ./system/database/drivers/sqlsrv/sqlsrv_driver.php */
\ No newline at end of file
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index 531d1d3..5f0427f 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -100,7 +100,7 @@
 		$datestr = str_replace(
 			'%\\',
 			'',
-			preg_replace("/([a-z]+?){1}/i", "\\\\\\1", $datestr)
+			preg_replace('/([a-z]+?){1}/i', '\\\\\\1', $datestr)
 		);
 
 		return date($datestr, $time);
@@ -316,12 +316,12 @@
 		}
 
 		return mktime(
-			gmdate("H", $time),
-			gmdate("i", $time),
-			gmdate("s", $time),
-			gmdate("m", $time),
-			gmdate("d", $time),
-			gmdate("Y", $time)
+			gmdate('H', $time),
+			gmdate('i', $time),
+			gmdate('s', $time),
+			gmdate('m', $time),
+			gmdate('d', $time),
+			gmdate('Y', $time)
 		);
 	}
 }
@@ -452,8 +452,7 @@
 			return FALSE;
 		}
 
-		$datestr = trim($datestr);
-		$datestr = preg_replace("/\040+/", ' ', $datestr);
+		$datestr = preg_replace('/\040+/', ' ', trim($datestr));
 
 		if ( ! preg_match('/^[0-9]{2,4}\-[0-9]{1,2}\-[0-9]{1,2}\s[0-9]{1,2}:[0-9]{1,2}(?::[0-9]{1,2})?(?:\s[AP]M)?$/i', $datestr))
 		{
@@ -462,20 +461,20 @@
 
 		$split = explode(' ', $datestr);
 
-		$ex = explode("-", $split['0']);
+		$ex = explode('-', $split['0']);
 
-		$year  = (strlen($ex['0']) == 2) ? '20'.$ex['0'] : $ex['0'];
-		$month = (strlen($ex['1']) == 1) ? '0'.$ex['1']  : $ex['1'];
-		$day   = (strlen($ex['2']) == 1) ? '0'.$ex['2']  : $ex['2'];
+		$year  = (strlen($ex[0]) === 2) ? '20'.$ex[0] : $ex[0];
+		$month = (strlen($ex[1]) === 1) ? '0'.$ex[1]  : $ex[1];
+		$day   = (strlen($ex[2]) === 1) ? '0'.$ex[2]  : $ex[2];
 
-		$ex = explode(":", $split['1']);
+		$ex = explode(':', $split['1']);
 
-		$hour = (strlen($ex['0']) == 1) ? '0'.$ex['0'] : $ex['0'];
-		$min  = (strlen($ex['1']) == 1) ? '0'.$ex['1'] : $ex['1'];
+		$hour = (strlen($ex[0]) === 1) ? '0'.$ex[0] : $ex[0];
+		$min  = (strlen($ex[1]) === 1) ? '0'.$ex[1] : $ex[1];
 
-		if (isset($ex['2']) && preg_match('/[0-9]{1,2}/', $ex['2']))
+		if (isset($ex['2']) && preg_match('/[0-9]{1,2}/', $ex[2]))
 		{
-			$sec  = (strlen($ex['2']) == 1) ? '0'.$ex['2'] : $ex['2'];
+			$sec  = (strlen($ex[2]) === 1) ? '0'.$ex[2] : $ex[2];
 		}
 		else
 		{
@@ -485,11 +484,11 @@
 
 		if (isset($split['2']))
 		{
-			$ampm = strtolower($split['2']);
+			$ampm = strtolower($split[2]);
 
 			if (substr($ampm, 0, 1) === 'p' && $hour < 12)
 			{
-				$hour = $hour + 12;
+				$hour += 12;
 			}
 
 			if (substr($ampm, 0, 1) === 'a' && $hour == 12)
@@ -497,7 +496,7 @@
 				$hour =  '00';
 			}
 
-			if (strlen($hour) == 1)
+			if (strlen($hour) === 1)
 			{
 				$hour = '0'.$hour;
 			}
@@ -529,7 +528,7 @@
 		// Date like: YYYYMM
 		if (preg_match('/^\d{6}$/', $bad_date))
 		{
-			if (in_array(substr($bad_date, 0, 2),array('19', '20')))
+			if (in_array(substr($bad_date, 0, 2), array('19', '20')))
 			{
 				$year  = substr($bad_date, 0, 4);
 				$month = substr($bad_date, 4, 2);
@@ -540,24 +539,24 @@
 				$year   = substr($bad_date, 2, 4);
 			}
 
-			return date($format, strtotime($year . '-' . $month . '-01'));
+			return date($format, strtotime($year.'-'.$month.'-01'));
 		}
 
 		// Date Like: YYYYMMDD
-		if (preg_match('/^\d{8}$/',$bad_date))
+		if (preg_match('/^\d{8}$/', $bad_date))
 		{
 			$month = substr($bad_date, 0, 2);
 			$day   = substr($bad_date, 2, 2);
 			$year  = substr($bad_date, 4, 4);
 
-			return date($format, strtotime($month . '/01/' . $year));
+			return date($format, strtotime($month.'/01/'.$year));
 		}
 
 		// Date Like: MM-DD-YYYY __or__ M-D-YYYY (or anything in between)
-		if (preg_match('/^\d{1,2}-\d{1,2}-\d{4}$/',$bad_date))
+		if (preg_match('/^\d{1,2}-\d{1,2}-\d{4}$/', $bad_date))
 		{
 			list($m, $d, $y) = explode('-', $bad_date);
-			return date($format, strtotime("{$y}-{$m}-{$d}"));
+			return date($format, strtotime($y.'-'.$m.'-'.$d));
 		}
 
 		// Any other kind of string, when converted into UNIX time,
@@ -565,7 +564,7 @@
 		// return "Invalid Date".
 		if (date('U', strtotime($bad_date)) == '0')
 		{
-			return "Invalid Date";
+			return 'Invalid Date';
 		}
 
 		// It's probably a valid-ish date format already
@@ -587,7 +586,7 @@
 	 * @param	string	menu name
 	 * @return	string
 	 */
-	function timezone_menu($default = 'UTC', $class = "", $name = 'timezones')
+	function timezone_menu($default = 'UTC', $class = '', $name = 'timezones')
 	{
 		$CI =& get_instance();
 		$CI->lang->load('date');
@@ -605,13 +604,11 @@
 
 		foreach (timezones() as $key => $val)
 		{
-			$selected = ($default == $key) ? " selected='selected'" : '';
-			$menu .= "<option value='{$key}'{$selected}>".$CI->lang->line($key)."</option>\n";
+			$selected = ($default == $key) ? ' selected="selected"' : '';
+			$menu .= '<option value="'.$key.'"'.$selected.'>'.$CI->lang->line($key)."</option>\n";
 		}
 
-		$menu .= "</select>";
-
-		return $menu;
+		return $menu.'</select>';
 	}
 }
 
diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php
index 97e6986..470b61e 100644
--- a/system/helpers/download_helper.php
+++ b/system/helpers/download_helper.php
@@ -100,7 +100,7 @@
 			$x[count($x) - 1] = strtoupper($extension);
 			$filename = implode('.', $x);
 		}
-		
+
 		// Clean output buffer
 		ob_clean();
 
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index b246d72..eca6c5f 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -184,7 +184,6 @@
 
 // ------------------------------------------------------------------------
 
-
 if ( ! function_exists('form_password'))
 {
 	/**
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index 124f580..92a6db4 100644
--- a/system/helpers/html_helper.php
+++ b/system/helpers/html_helper.php
@@ -379,10 +379,10 @@
 		$str = '';
 		foreach ($name as $meta)
 		{
-			$type		= ( ! isset($meta['type']) OR $meta['type'] == 'name') ? 'name' : 'http-equiv';
-			$name		= ( ! isset($meta['name']))		? ''	: $meta['name'];
-			$content	= ( ! isset($meta['content']))	? ''	: $meta['content'];
-			$newline	= ( ! isset($meta['newline']))	? "\n"	: $meta['newline'];
+			$type		= ( ! isset($meta['type']) OR $meta['type'] === 'name') ? 'name' : 'http-equiv';
+			$name		= isset($meta['name'])					? $meta['name'] : '';
+			$content	= isset($meta['content'])				? $meta['content'] : '';
+			$newline	= isset($meta['newline'])				? $meta['newline'] : "\n";
 
 			$str .= '<meta '.$type.'="'.$name.'" content="'.$content.'" />'.$newline;
 		}
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
index feeaf57..647d840 100644
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -37,16 +37,16 @@
 
 // --------------------------------------------------------------------
 
-/**
- * Singular
- *
- * Takes a plural word and makes it singular
- *
- * @param	string
- * @return	str
- */
 if ( ! function_exists('singular'))
 {
+	/**
+	 * Singular
+	 *
+	 * Takes a plural word and makes it singular
+	 *
+	 * @param	string
+	 * @return	string
+	 */
 	function singular($str)
 	{
 		$result = strval($str);
@@ -101,17 +101,17 @@
 
 // --------------------------------------------------------------------
 
-/**
- * Plural
- *
- * Takes a singular word and makes it plural
- *
- * @param	string
- * @param	bool
- * @return	str
- */
 if ( ! function_exists('plural'))
 {
+	/**
+	 * Plural
+	 *
+	 * Takes a singular word and makes it plural
+	 *
+	 * @param	string
+	 * @param	bool
+	 * @return	string
+	 */
 	function plural($str, $force = FALSE)
 	{
 		$result = strval($str);
@@ -158,16 +158,16 @@
 
 // --------------------------------------------------------------------
 
-/**
- * Camelize
- *
- * Takes multiple words separated by spaces or underscores and camelizes them
- *
- * @param	string
- * @return	str
- */
 if ( ! function_exists('camelize'))
 {
+	/**
+	 * Camelize
+	 *
+	 * Takes multiple words separated by spaces or underscores and camelizes them
+	 *
+	 * @param	string
+	 * @return	string
+	 */
 	function camelize($str)
 	{
 		return strtolower($str[0]).substr(str_replace(' ', '', ucwords(preg_replace('/[\s_]+/', ' ', $str))), 1);
@@ -176,16 +176,16 @@
 
 // --------------------------------------------------------------------
 
-/**
- * Underscore
- *
- * Takes multiple words separated by spaces and underscores them
- *
- * @param	string
- * @return	str
- */
 if ( ! function_exists('underscore'))
 {
+	/**
+	 * Underscore
+	 *
+	 * Takes multiple words separated by spaces and underscores them
+	 *
+	 * @param	string
+	 * @return	string
+	 */
 	function underscore($str)
 	{
 		return preg_replace('/[\s]+/', '_', strtolower(trim($str)));
@@ -194,31 +194,33 @@
 
 // --------------------------------------------------------------------
 
-/**
- * Humanize
- *
- * Takes multiple words separated by the separator and changes them to spaces
- *
- * @param	string	$str
- * @param 	string	$separator
- * @return	str
- */
 if ( ! function_exists('humanize'))
 {
+	/**
+	 * Humanize
+	 *
+	 * Takes multiple words separated by the separator and changes them to spaces
+	 *
+	 * @param	string	$str
+	 * @param 	string	$separator
+	 * @return	string
+	 */
 	function humanize($str, $separator = '_')
 	{
 		return ucwords(preg_replace('/['.$separator.']+/', ' ', strtolower(trim($str))));
 	}
 }
 
-/**
- * Checks if the given word has a plural version.
- *
- * @param	string	the word to check
- * @return	bool	if the word is countable
- */
+// --------------------------------------------------------------------
+
 if ( ! function_exists('is_countable'))
 {
+	/**
+	 * Checks if the given word has a plural version.
+	 *
+	 * @param	string	the word to check
+	 * @return	bool	if the word is countable
+	 */
 	function is_countable($word)
 	{
 		return ! in_array(strtolower(strval($word)),
diff --git a/system/helpers/language_helper.php b/system/helpers/language_helper.php
index b31c971..34f0307 100644
--- a/system/helpers/language_helper.php
+++ b/system/helpers/language_helper.php
@@ -37,17 +37,17 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Lang
- *
- * Fetches a language variable and optionally outputs a form label
- *
- * @param	string	the language line
- * @param	string	the id of the form element
- * @return	string
- */
 if ( ! function_exists('lang'))
 {
+	/**
+	 * Lang
+	 *
+	 * Fetches a language variable and optionally outputs a form label
+	 *
+	 * @param	string	the language line
+	 * @param	string	the id of the form element
+	 * @return	string
+	 */
 	function lang($line, $id = '')
 	{
 		$CI =& get_instance();
diff --git a/system/helpers/number_helper.php b/system/helpers/number_helper.php
index 40da6e7..e49f2f7 100644
--- a/system/helpers/number_helper.php
+++ b/system/helpers/number_helper.php
@@ -37,14 +37,15 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Formats a numbers as bytes, based on size, and adds the appropriate suffix
- *
- * @param	mixed	// will be cast as int
- * @return	string
- */
 if ( ! function_exists('byte_format'))
 {
+	/**
+	 * Formats a numbers as bytes, based on size, and adds the appropriate suffix
+	 *
+	 * @param	mixed	will be cast as int
+	 * @param	int
+	 * @return	string
+	 */
 	function byte_format($num, $precision = 1)
 	{
 		$CI =& get_instance();
diff --git a/system/helpers/path_helper.php b/system/helpers/path_helper.php
index 6ee9907..1341054 100644
--- a/system/helpers/path_helper.php
+++ b/system/helpers/path_helper.php
@@ -37,15 +37,15 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Set Realpath
- *
- * @param	string
- * @param	bool	checks to see if the path exists
- * @return	string
- */
 if ( ! function_exists('set_realpath'))
 {
+	/**
+	 * Set Realpath
+	 *
+	 * @param	string
+	 * @param	bool	checks to see if the path exists
+	 * @return	string
+	 */
 	function set_realpath($path, $check_existance = FALSE)
 	{
 		// Security check to make sure the path is NOT a URL. No remote file inclusion!
diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php
index d6f134c..6187a4a 100644
--- a/system/helpers/security_helper.php
+++ b/system/helpers/security_helper.php
@@ -37,15 +37,15 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * XSS Filtering
- *
- * @param	string
- * @param	bool	whether or not the content is an image file
- * @return	string
- */
 if ( ! function_exists('xss_clean'))
 {
+	/**
+	 * XSS Filtering
+	 *
+	 * @param	string
+	 * @param	bool	whether or not the content is an image file
+	 * @return	string
+	 */
 	function xss_clean($str, $is_image = FALSE)
 	{
 		$CI =& get_instance();
@@ -55,14 +55,14 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Sanitize Filename
- *
- * @param	string
- * @return	string
- */
 if ( ! function_exists('sanitize_filename'))
 {
+	/**
+	 * Sanitize Filename
+	 *
+	 * @param	string
+	 * @return	string
+	 */
 	function sanitize_filename($filename)
 	{
 		$CI =& get_instance();
@@ -72,14 +72,15 @@
 
 // --------------------------------------------------------------------
 
-/**
- * Hash encode a string
- *
- * @param	string
- * @return	string
- */
 if ( ! function_exists('do_hash'))
 {
+	/**
+	 * Hash encode a string
+	 *
+	 * @param	string
+	 * @param	string
+	 * @return	string
+	 */
 	function do_hash($str, $type = 'sha1')
 	{
 		if ( ! in_array(strtolower($type), hash_algos()))
@@ -93,14 +94,14 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Strip Image Tags
- *
- * @param	string
- * @return	string
- */
 if ( ! function_exists('strip_image_tags'))
 {
+	/**
+	 * Strip Image Tags
+	 *
+	 * @param	string
+	 * @return	string
+	 */
 	function strip_image_tags($str)
 	{
 		return preg_replace(array('#<img\s+.*?src\s*=\s*["\'](.+?)["\'].*?\>#', '#<img\s+.*?src\s*=\s*(.+?).*?\>#'), '\\1', $str);
@@ -109,14 +110,14 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Convert PHP tags to entities
- *
- * @param	string
- * @return	string
- */
 if ( ! function_exists('encode_php_tags'))
 {
+	/**
+	 * Convert PHP tags to entities
+	 *
+	 * @param	string
+	 * @return	string
+	 */
 	function encode_php_tags($str)
 	{
 		return str_replace(array('<?php', '<?PHP', '<?', '?>'),  array('&lt;?php', '&lt;?PHP', '&lt;?', '?&gt;'), $str);
diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php
index 638100e..5e6de08 100644
--- a/system/helpers/smiley_helper.php
+++ b/system/helpers/smiley_helper.php
@@ -37,18 +37,19 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Smiley Javascript
- *
- * Returns the javascript required for the smiley insertion. Optionally takes
- * an array of aliases to loosely couple the smiley array to the view.
- *
- * @param	mixed	alias name or array of alias->field_id pairs
- * @param	string	field_id if alias name was passed in
- * @return	array
- */
 if ( ! function_exists('smiley_js'))
 {
+	/**
+	 * Smiley Javascript
+	 *
+	 * Returns the javascript required for the smiley insertion.  Optionally takes
+	 * an array of aliases to loosely couple the smiley array to the view.
+	 *
+	 * @param	mixed	alias name or array of alias->field_id pairs
+	 * @param	string	field_id if alias name was passed in
+	 * @param	bool
+	 * @return	array
+	 */
 	function smiley_js($alias = '', $field_id = '', $inline = TRUE)
 	{
 		static $do_setup = TRUE;
@@ -118,17 +119,20 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Get Clickable Smileys
- *
- * Returns an array of image tag links that can be clicked to be inserted
- * into a form field.
- *
- * @param	string	the URL to the folder containing the smiley images
- * @return	array
- */
+
 if ( ! function_exists('get_clickable_smileys'))
 {
+	/**
+	 * Get Clickable Smileys
+	 *
+	 * Returns an array of image tag links that can be clicked to be inserted
+	 * into a form field.
+	 *
+	 * @param	string	the URL to the folder containing the smiley images
+	 * @param	array
+	 * @param	array
+	 * @return	array
+	 */
 	function get_clickable_smileys($image_url, $alias = '', $smileys = NULL)
 	{
 		// For backward compatibility with js_insert_smiley
@@ -166,17 +170,18 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Parse Smileys
- *
- * Takes a string as input and swaps any contained smileys for the actual image
- *
- * @param	string	the text to be parsed
- * @param	string	the URL to the folder containing the smiley images
- * @return	string
- */
 if ( ! function_exists('parse_smileys'))
 {
+	/**
+	 * Parse Smileys
+	 *
+	 * Takes a string as input and swaps any contained smileys for the actual image
+	 *
+	 * @param	string	the text to be parsed
+	 * @param	string	the URL to the folder containing the smiley images
+	 * @param	array
+	 * @return	string
+	 */
 	function parse_smileys($str = '', $image_url = '', $smileys = NULL)
 	{
 		if ($image_url == '' OR ( ! is_array($smileys) && FALSE === ($smileys = _get_smiley_array())))
@@ -198,15 +203,15 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Get Smiley Array
- *
- * Fetches the config/smiley.php file
- *
- * @return	mixed
- */
 if ( ! function_exists('_get_smiley_array'))
 {
+	/**
+	 * Get Smiley Array
+	 *
+	 * Fetches the config/smiley.php file
+	 *
+	 * @return	mixed
+	 */
 	function _get_smiley_array()
 	{
 		if (defined('ENVIRONMENT') && file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'))
@@ -222,33 +227,5 @@
 	}
 }
 
-// ------------------------------------------------------------------------
-
-/**
- * JS Insert Smiley
- *
- * Generates the javascript function needed to insert smileys into a form field
- *
- * DEPRECATED as of version 1.7.2, use smiley_js instead
- *
- * @param	string	form name
- * @param	string	field name
- * @return	string
- */
-if ( ! function_exists('js_insert_smiley'))
-{
-	function js_insert_smiley($form_name = '', $form_field = '')
-	{
-		return <<<EOF
-<script type="text/javascript">
-	function insert_smiley(smiley)
-	{
-		document.{$form_name}.{$form_field}.value += " " + smiley;
-	}
-</script>
-EOF;
-	}
-}
-
 /* End of file smiley_helper.php */
 /* Location: ./system/helpers/smiley_helper.php */
\ No newline at end of file
diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php
index a6a6b48..0c47d44 100644
--- a/system/helpers/string_helper.php
+++ b/system/helpers/string_helper.php
@@ -37,22 +37,22 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Trim Slashes
- *
- * Removes any leading/trailing slashes from a string:
- *
- * /this/that/theother/
- *
- * becomes:
- *
- * this/that/theother
- *
- * @param	string
- * @return	string
- */
 if ( ! function_exists('trim_slashes'))
 {
+	/**
+	 * Trim Slashes
+	 *
+	 * Removes any leading/trailing slashes from a string:
+	 *
+	 * /this/that/theother/
+	 *
+	 * becomes:
+	 *
+	 * this/that/theother
+	 *
+	 * @param	string
+	 * @return	string
+	 */
 	function trim_slashes($str)
 	{
 		return trim($str, '/');
@@ -61,16 +61,16 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Strip Slashes
- *
- * Removes slashes contained in a string or in an array
- *
- * @param	mixed	string or array
- * @return	mixed	string or array
- */
 if ( ! function_exists('strip_slashes'))
 {
+	/**
+	 * Strip Slashes
+	 *
+	 * Removes slashes contained in a string or in an array
+	 *
+	 * @param	mixed	string or array
+	 * @return	mixed	string or array
+	 */
 	function strip_slashes($str)
 	{
 		if ( ! is_array($str))
@@ -89,16 +89,16 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Strip Quotes
- *
- * Removes single and double quotes from a string
- *
- * @param	string
- * @return	string
- */
 if ( ! function_exists('strip_quotes'))
 {
+	/**
+	 * Strip Quotes
+	 *
+	 * Removes single and double quotes from a string
+	 *
+	 * @param	string
+	 * @return	string
+	 */
 	function strip_quotes($str)
 	{
 		return str_replace(array('"', "'"), '', $str);
@@ -107,16 +107,16 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Quotes to Entities
- *
- * Converts single and double quotes to entities
- *
- * @param	string
- * @return	string
- */
 if ( ! function_exists('quotes_to_entities'))
 {
+	/**
+	 * Quotes to Entities
+	 *
+	 * Converts single and double quotes to entities
+	 *
+	 * @param	string
+	 * @return	string
+	 */
 	function quotes_to_entities($str)
 	{
 		return str_replace(array("\'","\"","'",'"'), array("&#39;","&quot;","&#39;","&quot;"), $str);
@@ -125,23 +125,23 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Reduce Double Slashes
- *
- * Converts double slashes in a string to a single slash,
- * except those found in http://
- *
- * http://www.some-site.com//index.php
- *
- * becomes:
- *
- * http://www.some-site.com/index.php
- *
- * @param	string
- * @return	string
- */
 if ( ! function_exists('reduce_double_slashes'))
 {
+	/**
+	 * Reduce Double Slashes
+	 *
+	 * Converts double slashes in a string to a single slash,
+	 * except those found in http://
+	 *
+	 * http://www.some-site.com//index.php
+	 *
+	 * becomes:
+	 *
+	 * http://www.some-site.com/index.php
+	 *
+	 * @param	string
+	 * @return	string
+	 */
 	function reduce_double_slashes($str)
 	{
 		return preg_replace('#(^|[^:])//+#', '\\1/', $str);
@@ -150,24 +150,24 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Reduce Multiples
- *
- * Reduces multiple instances of a particular character.  Example:
- *
- * Fred, Bill,, Joe, Jimmy
- *
- * becomes:
- *
- * Fred, Bill, Joe, Jimmy
- *
- * @param	string
- * @param	string	the character you wish to reduce
- * @param	bool	TRUE/FALSE - whether to trim the character from the beginning/end
- * @return	string
- */
 if ( ! function_exists('reduce_multiples'))
 {
+	/**
+	 * Reduce Multiples
+	 *
+	 * Reduces multiple instances of a particular character.  Example:
+	 *
+	 * Fred, Bill,, Joe, Jimmy
+	 *
+	 * becomes:
+	 *
+	 * Fred, Bill, Joe, Jimmy
+	 *
+	 * @param	string
+	 * @param	string	the character you wish to reduce
+	 * @param	bool	TRUE/FALSE - whether to trim the character from the beginning/end
+	 * @return	string
+	 */
 	function reduce_multiples($str, $character = ',', $trim = FALSE)
 	{
 		$str = preg_replace('#'.preg_quote($character, '#').'{2,}#', $character, $str);
@@ -177,17 +177,17 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Create a Random String
- *
- * Useful for generating passwords or hashes.
- *
- * @param	string	type of random string.  basic, alpha, alunum, numeric, nozero, unique, md5, encrypt and sha1
- * @param	int	number of characters
- * @return	string
- */
 if ( ! function_exists('random_string'))
 {
+	/**
+	 * Create a Random String
+	 *
+	 * Useful for generating passwords or hashes.
+	 *
+	 * @param	string	type of random string.  basic, alpha, alunum, numeric, nozero, unique, md5, encrypt and sha1
+	 * @param	int	number of characters
+	 * @return	string
+	 */
 	function random_string($type = 'alnum', $len = 8)
 	{
 		switch ($type)
@@ -226,16 +226,16 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Add's _1 to a string or increment the ending number to allow _2, _3, etc
- *
- * @param	string	required
- * @param	string	What should the duplicate number be appended with
- * @param	string	Which number should be used for the first dupe increment
- * @return	string
- */
 if ( ! function_exists('increment_string'))
 {
+	/**
+	 * Add's _1 to a string or increment the ending number to allow _2, _3, etc
+	 *
+	 * @param	string	required
+	 * @param	string	What should the duplicate number be appended with
+	 * @param	string	Which number should be used for the first dupe increment
+	 * @return	string
+	 */
 	function increment_string($str, $separator = '_', $first = 1)
 	{
 		preg_match('/(.+)'.$separator.'([0-9]+)$/', $str, $match);
@@ -245,17 +245,17 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Alternator
- *
- * Allows strings to be alternated. See docs...
- *
- * @param	string	(as many parameters as needed)
- * @return	string
- */
 if ( ! function_exists('alternator'))
 {
-	function alternator()
+	/**
+	 * Alternator
+	 *
+	 * Allows strings to be alternated. See docs...
+	 *
+	 * @param	string (as many parameters as needed)
+	 * @return	string
+	 */
+	function alternator($args)
 	{
 		static $i;
 
@@ -271,15 +271,15 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Repeater function
- *
- * @param	string
- * @param	int	number of repeats
- * @return	string
- */
 if ( ! function_exists('repeater'))
 {
+	/**
+	 * Repeater function
+	 *
+	 * @param	string
+	 * @param	int	number of repeats
+	 * @return	string
+	 */
 	function repeater($data, $num = 1)
 	{
 		return ($num > 0) ? str_repeat($data, $num) : '';
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index c1c0eb9..e4451ae 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -37,18 +37,18 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Word Limiter
- *
- * Limits a string to X number of words.
- *
- * @param	string
- * @param	int
- * @param	string	the end character. Usually an ellipsis
- * @return	string
- */
 if ( ! function_exists('word_limiter'))
 {
+	/**
+	 * Word Limiter
+	 *
+	 * Limits a string to X number of words.
+	 *
+	 * @param	string
+	 * @param	int
+	 * @param	string	the end character. Usually an ellipsis
+	 * @return	string
+	 */
 	function word_limiter($str, $limit = 100, $end_char = '&#8230;')
 	{
 		if (trim($str) == '')
@@ -69,19 +69,19 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Character Limiter
- *
- * Limits the string based on the character count. Preserves complete words
- * so the character count may not be exactly as specified.
- *
- * @param	string
- * @param	int
- * @param	string	the end character. Usually an ellipsis
- * @return	string
- */
 if ( ! function_exists('character_limiter'))
 {
+	/**
+	 * Character Limiter
+	 *
+	 * Limits the string based on the character count.  Preserves complete words
+	 * so the character count may not be exactly as specified.
+	 *
+	 * @param	string
+	 * @param	int
+	 * @param	string	the end character. Usually an ellipsis
+	 * @return	string
+	 */
 	function character_limiter($str, $n = 500, $end_char = '&#8230;')
 	{
 		if (strlen($str) < $n)
@@ -112,16 +112,16 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * High ASCII to Entities
- *
- * Converts High ascii text and MS Word special characters to character entities
- *
- * @param	string
- * @return	string
- */
 if ( ! function_exists('ascii_to_entities'))
 {
+	/**
+	 * High ASCII to Entities
+	 *
+	 * Converts High ascii text and MS Word special characters to character entities
+	 *
+	 * @param	string
+	 * @return	string
+	 */
 	function ascii_to_entities($str)
 	{
 		$count	= 1;
@@ -174,17 +174,17 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Entities to ASCII
- *
- * Converts character entities back to ASCII
- *
- * @param	string
- * @param	bool
- * @return	string
- */
 if ( ! function_exists('entities_to_ascii'))
 {
+	/**
+	 * Entities to ASCII
+	 *
+	 * Converts character entities back to ASCII
+	 *
+	 * @param	string
+	 * @param	bool
+	 * @return	string
+	 */
 	function entities_to_ascii($str, $all = TRUE)
 	{
 		if (preg_match_all('/\&#(\d+)\;/', $str, $matches))
@@ -227,20 +227,20 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Word Censoring Function
- *
- * Supply a string and an array of disallowed words and any
- * matched words will be converted to #### or to the replacement
- * word you've submitted.
- *
- * @param	string	the text string
- * @param	string	the array of censoered words
- * @param	string	the optional replacement value
- * @return	string
- */
 if ( ! function_exists('word_censor'))
 {
+	/**
+	 * Word Censoring Function
+	 *
+	 * Supply a string and an array of disallowed words and any
+	 * matched words will be converted to #### or to the replacement
+	 * word you've submitted.
+	 *
+	 * @param	string	the text string
+	 * @param	string	the array of censoered words
+	 * @param	string	the optional replacement value
+	 * @return	string
+	 */
 	function word_censor($str, $censored, $replacement = '')
 	{
 		if ( ! is_array($censored))
@@ -274,16 +274,16 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Code Highlighter
- *
- * Colorizes code strings
- *
- * @param	string	the text string
- * @return	string
- */
 if ( ! function_exists('highlight_code'))
 {
+	/**
+	 * Code Highlighter
+	 *
+	 * Colorizes code strings
+	 *
+	 * @param	string	the text string
+	 * @return	string
+	 */
 	function highlight_code($str)
 	{
 		/* The highlight string function encodes and highlights
@@ -323,19 +323,19 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Phrase Highlighter
- *
- * Highlights a phrase within a text string
- *
- * @param	string	the text string
- * @param	string	the phrase you'd like to highlight
- * @param	string	the openging tag to precede the phrase with
- * @param	string	the closing tag to end the phrase with
- * @return	string
- */
 if ( ! function_exists('highlight_phrase'))
 {
+	/**
+	 * Phrase Highlighter
+	 *
+	 * Highlights a phrase within a text string
+	 *
+	 * @param	string	the text string
+	 * @param	string	the phrase you'd like to highlight
+	 * @param	string	the openging tag to precede the phrase with
+	 * @param	string	the closing tag to end the phrase with
+	 * @return	string
+	 */
 	function highlight_phrase($str, $phrase, $tag_open = '<strong>', $tag_close = '</strong>')
 	{
 		if ($str == '')
@@ -354,14 +354,14 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Convert Accented Foreign Characters to ASCII
- *
- * @param	string	the text string
- * @return	string
- */
 if ( ! function_exists('convert_accented_characters'))
 {
+	/**
+	 * Convert Accented Foreign Characters to ASCII
+	 *
+	 * @param	string	the text string
+	 * @return	string
+	 */
 	function convert_accented_characters($str)
 	{
 		global $foreign_characters;
@@ -490,19 +490,19 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Ellipsize String
- *
- * This function will strip tags from a string, split it at its max_length and ellipsize
- *
- * @param	string	string to ellipsize
- * @param	int	max length of string
- * @param	mixed	int (1|0) or float, .5, .2, etc for position to split
- * @param	string	ellipsis ; Default '...'
- * @return	string	ellipsized string
- */
 if ( ! function_exists('ellipsize'))
 {
+	/**
+	 * Ellipsize String
+	 *
+	 * This function will strip tags from a string, split it at its max_length and ellipsize
+	 *
+	 * @param	string	string to ellipsize
+	 * @param	int	max length of string
+	 * @param	mixed	int (1|0) or float, .5, .2, etc for position to split
+	 * @param	string	ellipsis ; Default '...'
+	 * @return	string	ellipsized string
+	 */
 	function ellipsize($str, $max_length, $position = 1, $ellipsis = '&hellip;')
 	{
 		// Strip tags
diff --git a/system/helpers/typography_helper.php b/system/helpers/typography_helper.php
index 7a3db5d..af9d16a 100644
--- a/system/helpers/typography_helper.php
+++ b/system/helpers/typography_helper.php
@@ -37,14 +37,14 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Convert newlines to HTML line breaks except within PRE tags
- *
- * @param	string
- * @return	string
- */
 if ( ! function_exists('nl2br_except_pre'))
 {
+	/**
+	 * Convert newlines to HTML line breaks except within PRE tags
+	 *
+	 * @param	string
+	 * @return	string
+	 */
 	function nl2br_except_pre($str)
 	{
 		$CI =& get_instance();
@@ -55,16 +55,16 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Auto Typography Wrapper Function
- *
- * @param	string
- * @param	bool	whether to allow javascript event handlers
- * @param	bool	whether to reduce multiple instances of double newlines to two
- * @return	string
- */
 if ( ! function_exists('auto_typography'))
 {
+	/**
+	 * Auto Typography Wrapper Function
+	 *
+	 * @param	string
+	 * @param	bool	whether to allow javascript event handlers
+	 * @param	bool	whether to reduce multiple instances of double newlines to two
+	 * @return	string
+	 */
 	function auto_typography($str, $strip_js_event_handlers = TRUE, $reduce_linebreaks = FALSE)
 	{
 		$CI =& get_instance();
@@ -73,20 +73,19 @@
 	}
 }
 
-
 // --------------------------------------------------------------------
 
-/**
- * HTML Entities Decode
- *
- * This function is a replacement for html_entity_decode()
- *
- * @param	string
- * @param	string
- * @return	string
- */
 if ( ! function_exists('entity_decode'))
 {
+	/**
+	 * HTML Entities Decode
+	 *
+	 * This function is a replacement for html_entity_decode()
+	 *
+	 * @param	string
+	 * @param	string
+	 * @return	string
+	 */
 	function entity_decode($str, $charset = NULL)
 	{
 		global $SEC;
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index 5576c27..0e933c1 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -37,17 +37,17 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Site URL
- *
- * Create a local URL based on your basepath. Segments can be passed via the
- * first parameter either as a string or an array.
- *
- * @param	string
- * @return	string
- */
 if ( ! function_exists('site_url'))
 {
+	/**
+	 * Site URL
+	 *
+	 * Create a local URL based on your basepath. Segments can be passed via the
+	 * first parameter either as a string or an array.
+	 *
+	 * @param	string
+	 * @return	string
+	 */
 	function site_url($uri = '')
 	{
 		$CI =& get_instance();
@@ -57,18 +57,18 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Base URL
- *
- * Create a local URL based on your basepath.
- * Segments can be passed in as a string or an array, same as site_url
- * or a URL to a file can be passed in, e.g. to an image file.
- *
- * @param	string
- * @return	string
- */
 if ( ! function_exists('base_url'))
 {
+	/**
+	 * Base URL
+	 *
+	 * Create a local URL based on your basepath.
+	 * Segments can be passed in as a string or an array, same as site_url
+	 * or a URL to a file can be passed in, e.g. to an image file.
+	 *
+	 * @param	string
+	 * @return	string
+	 */
 	function base_url($uri = '')
 	{
 		$CI =& get_instance();
@@ -78,16 +78,16 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Current URL
- *
- * Returns the full URL (including segments) of the page where this
- * function is placed
- *
- * @return	string
- */
 if ( ! function_exists('current_url'))
 {
+	/**
+	 * Current URL
+	 *
+	 * Returns the full URL (including segments) of the page where this
+	 * function is placed
+	 *
+	 * @return	string
+	 */
 	function current_url()
 	{
 		$CI =& get_instance();
@@ -96,15 +96,16 @@
 }
 
 // ------------------------------------------------------------------------
-/**
- * URL String
- *
- * Returns the URI segments.
- *
- * @return	string
- */
+
 if ( ! function_exists('uri_string'))
 {
+	/**
+	 * URL String
+	 *
+	 * Returns the URI segments.
+	 *
+	 * @return	string
+	 */
 	function uri_string()
 	{
 		$CI =& get_instance();
@@ -114,15 +115,15 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Index page
- *
- * Returns the "index_page" from your config file
- *
- * @return	string
- */
 if ( ! function_exists('index_page'))
 {
+	/**
+	 * Index page
+	 *
+	 * Returns the "index_page" from your config file
+	 *
+	 * @return	string
+	 */
 	function index_page()
 	{
 		$CI =& get_instance();
@@ -132,18 +133,18 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Anchor Link
- *
- * Creates an anchor based on the local URL.
- *
- * @param	string	the URL
- * @param	string	the link title
- * @param	mixed	any attributes
- * @return	string
- */
 if ( ! function_exists('anchor'))
 {
+	/**
+	 * Anchor Link
+	 *
+	 * Creates an anchor based on the local URL.
+	 *
+	 * @param	string	the URL
+	 * @param	string	the link title
+	 * @param	mixed	any attributes
+	 * @return	string
+	 */
 	function anchor($uri = '', $title = '', $attributes = '')
 	{
 		$title = (string) $title;
@@ -173,19 +174,19 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Anchor Link - Pop-up version
- *
- * Creates an anchor based on the local URL. The link
- * opens a new window based on the attributes specified.
- *
- * @param	string	the URL
- * @param	string	the link title
- * @param	mixed	any attributes
- * @return	string
- */
 if ( ! function_exists('anchor_popup'))
 {
+	/**
+	 * Anchor Link - Pop-up version
+	 *
+	 * Creates an anchor based on the local URL. The link
+	 * opens a new window based on the attributes specified.
+	 *
+	 * @param	string	the URL
+	 * @param	string	the link title
+	 * @param	mixed	any attributes
+	 * @return	string
+	 */
 	function anchor_popup($uri = '', $title = '', $attributes = FALSE)
 	{
 		$title = (string) $title;
@@ -198,7 +199,7 @@
 
 		if ($attributes === FALSE)
 		{
-			return "<a href='javascript:void(0);' onclick=\"window.open('".$site_url."', '_blank');\">".$title.'</a>';
+			return '<a href="javascript:void(0);" onclick="window.open(\''.$site_url."', '_blank');\">".$title.'</a>';
 		}
 
 		if ( ! is_array($attributes))
@@ -217,22 +218,22 @@
 			$attributes = _parse_attributes($attributes);
 		}
 
-		return "<a href='javascript:void(0);' onclick=\"window.open('".$site_url."', '_blank', '"._parse_attributes($atts, TRUE)."');\"".$attributes.'>'.$title.'</a>';
+		return '<a href="javascript:void(0);" onclick="window.open(\''.$site_url."', '_blank', '"._parse_attributes($atts, TRUE)."');\"".$attributes.'>'.$title.'</a>';
 	}
 }
 
 // ------------------------------------------------------------------------
 
-/**
- * Mailto Link
- *
- * @param	string	the email address
- * @param	string	the link title
- * @param	mixed	any attributes
- * @return	string
- */
 if ( ! function_exists('mailto'))
 {
+	/**
+	 * Mailto Link
+	 *
+	 * @param	string	the email address
+	 * @param	string	the link title
+	 * @param	mixed	any attributes
+	 * @return	string
+	 */
 	function mailto($email, $title = '', $attributes = '')
 	{
 		$title = (string) $title;
@@ -248,18 +249,18 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Encoded Mailto Link
- *
- * Create a spam-protected mailto link written in Javascript
- *
- * @param	string	the email address
- * @param	string	the link title
- * @param	mixed	any attributes
- * @return	string
- */
 if ( ! function_exists('safe_mailto'))
 {
+	/**
+	 * Encoded Mailto Link
+	 *
+	 * Create a spam-protected mailto link written in Javascript
+	 *
+	 * @param	string	the email address
+	 * @param	string	the link title
+	 * @param	mixed	any attributes
+	 * @return	string
+	 */
 	function safe_mailto($email, $title = '', $attributes = '')
 	{
 		$title = (string) $title;
@@ -357,21 +358,21 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Auto-linker
- *
- * Automatically links URL and Email addresses.
- * Note: There's a bit of extra code here to deal with
- * URLs or emails that end in a period. We'll strip these
- * off and add them after the link.
- *
- * @param	string	the string
- * @param	string	the type: email, url, or both
- * @param	bool	whether to create pop-up links
- * @return	string
- */
 if ( ! function_exists('auto_link'))
 {
+	/**
+	 * Auto-linker
+	 *
+	 * Automatically links URL and Email addresses.
+	 * Note: There's a bit of extra code here to deal with
+	 * URLs or emails that end in a period. We'll strip these
+	 * off and add them after the link.
+	 *
+	 * @param	string	the string
+	 * @param	string	the type: email, url, or both
+	 * @param	bool	whether to create pop-up links
+	 * @return	string
+	 */
 	function auto_link($str, $type = 'both', $popup = FALSE)
 	{
 		if ($type !== 'email' && preg_match_all('#(^|\s|\(|\b)((http(s?)://)|(www\.))(\w+[^\s\)\<]+)#i', $str, $matches))
@@ -423,16 +424,16 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Prep URL
- *
- * Simply adds the http:// part if no scheme is included
- *
- * @param	string	the URL
- * @return	string
- */
 if ( ! function_exists('prep_url'))
 {
+	/**
+	 * Prep URL
+	 *
+	 * Simply adds the http:// part if no scheme is included
+	 *
+	 * @param	string	the URL
+	 * @return	string
+	 */
 	function prep_url($str = '')
 	{
 		if ($str === 'http://' OR $str == '')
@@ -453,20 +454,20 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Create URL Title
- *
- * Takes a "title" string as input and creates a
- * human-friendly URL string with a "separator" string
- * as the word separator.
- *
- * @param	string	the string
- * @param	string	the separator
- * @param	bool
- * @return	string
- */
 if ( ! function_exists('url_title'))
 {
+	/**
+	 * Create URL Title
+	 *
+	 * Takes a "title" string as input and creates a
+	 * human-friendly URL string with a "separator" string
+	 * as the word separator.
+	 *
+	 * @param	string	the string
+	 * @param	string	the separator
+	 * @param	bool
+	 * @return	string
+	 */
 	function url_title($str, $separator = '-', $lowercase = FALSE)
 	{
 		if ($separator === 'dash')
@@ -504,19 +505,20 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Header Redirect
- *
- * Header redirect in two flavors
- * For very fine grained control over headers, you could use the Output
- * Library's set_header() function.
- *
- * @param	string	the URL
- * @param	string	the method: location or refresh
- * @return	string
- */
 if ( ! function_exists('redirect'))
 {
+	/**
+	 * Header Redirect
+	 *
+	 * Header redirect in two flavors
+	 * For very fine grained control over headers, you could use the Output
+	 * Library's set_header() function.
+	 *
+	 * @param	string	the URL
+	 * @param	string	the method: location or refresh
+	 * @param	int
+	 * @return	string
+	 */
 	function redirect($uri = '', $method = 'auto', $http_response_code = 302)
 	{
 		if ( ! preg_match('#^https?://#i', $uri))
@@ -545,17 +547,17 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Parse out the attributes
- *
- * Some of the functions use this
- *
- * @param	array
- * @param	bool
- * @return	string
- */
 if ( ! function_exists('_parse_attributes'))
 {
+	/**
+	 * Parse out the attributes
+	 *
+	 * Some of the functions use this
+	 *
+	 * @param	array
+	 * @param	bool
+	 * @return	string
+	 */
 	function _parse_attributes($attributes, $javascript = FALSE)
 	{
 		if (is_string($attributes))
diff --git a/system/helpers/xml_helper.php b/system/helpers/xml_helper.php
index 67fd34b..958c633 100644
--- a/system/helpers/xml_helper.php
+++ b/system/helpers/xml_helper.php
@@ -37,15 +37,15 @@
 
 // ------------------------------------------------------------------------
 
-/**
- * Convert Reserved XML characters to Entities
- *
- * @param	string
- * @param	bool
- * @return	string
- */
 if ( ! function_exists('xml_convert'))
 {
+	/**
+	 * Convert Reserved XML characters to Entities
+	 *
+	 * @param	string
+	 * @param	bool
+	 * @return	string
+	 */
 	function xml_convert($str, $protect_all = FALSE)
 	{
 		$temp = '__TEMP_AMPERSANDS__';
diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php
index 0493d5a..ba732ee 100644
--- a/system/libraries/Cache/Cache.php
+++ b/system/libraries/Cache/Cache.php
@@ -55,14 +55,14 @@
 	 * @var string
 	 */
 	protected $_cache_path = NULL;
-	
+
 	/**
 	 * Reference to the driver
 	 *
 	 * @var mixed
 	 */
 	protected $_adapter = 'dummy';
-	
+
 	/**
 	 * Fallback driver
 	 *
diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php
index ec41952..f0eb8bd 100644
--- a/system/libraries/Cache/drivers/Cache_file.php
+++ b/system/libraries/Cache/drivers/Cache_file.php
@@ -45,6 +45,8 @@
 
 	/**
 	 * Initialize file-based cache
+	 *
+	 * @return	void
 	 */
 	public function __construct()
 	{
diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php
index 813df4b..1df149c 100644
--- a/system/libraries/Cache/drivers/Cache_memcached.php
+++ b/system/libraries/Cache/drivers/Cache_memcached.php
@@ -77,7 +77,7 @@
 	 * @param	string	unique identifier
 	 * @param	mixed	data being cached
 	 * @param	int	time to live
-	 * @return	bool true on success, false on failure
+	 * @return	bool	true on success, false on failure
 	 */
 	public function save($id, $data, $ttl = 60)
 	{
@@ -99,7 +99,7 @@
 	 * Delete from Cache
 	 *
 	 * @param	mixed	key to be deleted.
-	 * @return	bool true on success, false on failure
+	 * @return	bool	true on success, false on failure
 	 */
 	public function delete($id)
 	{
diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php
index 4db754f..92f372b 100644
--- a/system/libraries/Calendar.php
+++ b/system/libraries/Calendar.php
@@ -44,55 +44,55 @@
 	 * @var object
 	 */
 	protected $CI;
-	
+
 	/**
 	 * Current local time
 	 *
 	 * @var int
 	 */
 	public $local_time;
-	
+
 	/**
 	 * Calendar layout template
 	 *
 	 * @var string
 	 */
 	public $template		= '';
-	
+
 	/**
 	 * Day of the week to start the calendar on
 	 *
 	 * @var string
 	 */
 	public $start_day		= 'sunday';
-	
+
 	/**
 	 * How to display months
 	 *
 	 * @var string
 	 */
 	public $month_type		= 'long';
-	
+
 	/**
 	 * How to display names of days
 	 *
 	 * @var string
 	 */
 	public $day_type		= 'abr';
-	
+
 	/**
 	 * Whether to show next/prev month links
 	 *
 	 * @var bool
 	 */
-	public $show_next_prev	= FALSE;
-	
+	public $show_next_prev		= FALSE;
+
 	/**
 	 * Url base to use for next/prev month links
 	 *
 	 * @var bool
 	 */
-	public $next_prev_url	= '';
+	public $next_prev_url		= '';
 
 	/**
 	 * Constructor
@@ -187,7 +187,7 @@
 
 		// Set the starting day of the week
 		$start_days	= array('sunday' => 0, 'monday' => 1, 'tuesday' => 2, 'wednesday' => 3, 'thursday' => 4, 'friday' => 5, 'saturday' => 6);
-		$start_day = ( ! isset($start_days[$this->start_day])) ? 0 : $start_days[$this->start_day];
+		$start_day	= isset($start_days[$this->start_day]) ? $start_days[$this->start_day] : 0;
 
 		// Set the starting day number
 		$local_date = mktime(12, 0, 0, $month, 1, $year);
@@ -290,9 +290,7 @@
 			$out .= "\n".$this->temp['cal_row_end']."\n";
 		}
 
-		$out .= "\n".$this->temp['table_close'];
-
-		return $out;
+		return $out .= "\n".$this->temp['table_close'];
 	}
 
 	// --------------------------------------------------------------------
@@ -317,14 +315,9 @@
 			$month_names = array('01' => 'cal_january', '02' => 'cal_february', '03' => 'cal_march', '04' => 'cal_april', '05' => 'cal_mayl', '06' => 'cal_june', '07' => 'cal_july', '08' => 'cal_august', '09' => 'cal_september', '10' => 'cal_october', '11' => 'cal_november', '12' => 'cal_december');
 		}
 
-		$month = $month_names[$month];
-
-		if ($this->CI->lang->line($month) === FALSE)
-		{
-			return ucfirst(substr($month, 4));
-		}
-
-		return $this->CI->lang->line($month);
+		return ($this->CI->lang->line($month_names[$month]) === FALSE)
+			? ucfirst(substr($month_names[$month], 4))
+			: $this->CI->lang->line($month_names[$month]);
 	}
 
 	// --------------------------------------------------------------------
@@ -345,11 +338,11 @@
 			$this->day_type = $day_type;
 		}
 
-		if ($this->day_type == 'long')
+		if ($this->day_type === 'long')
 		{
 			$day_names = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
 		}
-		elseif ($this->day_type == 'short')
+		elseif ($this->day_type === 'short')
 		{
 			$day_names = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat');
 		}
@@ -448,7 +441,7 @@
 	 */
 	public function default_template()
 	{
-		return  array (
+		return  array(
 			'table_open'				=> '<table border="0" cellpadding="4" cellspacing="0">',
 			'heading_row_start'			=> '<tr>',
 			'heading_previous_cell'		=> '<th><a href="{previous_url}">&lt;&lt;</a></th>',
diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php
index 9f258be..8270503 100644
--- a/system/libraries/Cart.php
+++ b/system/libraries/Cart.php
@@ -39,11 +39,11 @@
 	/**
 	 * These are the regular expression rules that we use to validate the product ID and product name
 	 * alpha-numeric, dashes, underscores, or periods
-	 * 
+	 *
 	 * @var string
 	 */
 	public $product_id_rules	= '\.a-z0-9_-';
-	
+
 	/**
 	 * These are the regular expression rules that we use to validate the product ID and product name
 	 * alpha-numeric, dashes, underscores, colons or periods
@@ -51,7 +51,7 @@
 	 * @var string
 	 */
 	public $product_name_rules	= '\.\:\-_ a-z0-9';
-	
+
 	/**
 	 * only allow safe product names
 	 *
@@ -62,14 +62,14 @@
 	// --------------------------------------------------------------------------
 	// Protected variables. Do not change!
 	// --------------------------------------------------------------------------
-	
+
 	/**
 	 * Reference to CodeIgniter instance
 	 *
 	 * @var object
 	 */
 	protected $CI;
-	
+
 	/**
 	 * Contents of the cart
 	 *
@@ -83,6 +83,7 @@
 	 * The constructor loads the Session class, used to store the shopping cart contents.
 	 *
 	 * @param	array
+	 * @return	void
 	 */
 	public function __construct($params = array())
 	{
@@ -180,7 +181,7 @@
 		// --------------------------------------------------------------------
 
 		// Does the $items array contain an id, quantity, price, and name?  These are required
-		if ( ! isset($items['id']) OR ! isset($items['qty']) OR ! isset($items['price']) OR ! isset($items['name']))
+		if ( ! isset($items['id'], $items['qty'], $items['price'], $items['name']))
 		{
 			log_message('error', 'The cart array must contain a product ID, quantity, price, and name.');
 			return FALSE;
@@ -341,7 +342,7 @@
 	protected function _update($items = array())
 	{
 		// Without these array indexes there is nothing we can do
-		if ( ! isset($items['qty']) OR ! isset($items['rowid']) OR ! isset($this->_cart_contents[$items['rowid']]))
+		if ( ! isset($items['qty'], $items['rowid'], $this->_cart_contents[$items['rowid']]))
 		{
 			return FALSE;
 		}
@@ -383,7 +384,7 @@
 		foreach ($this->_cart_contents as $key => $val)
 		{
 			// We make sure the array contains the proper indexes
-			if ( ! is_array($val) OR ! isset($val['price']) OR ! isset($val['qty']))
+			if ( ! is_array($val) OR ! isset($val['price'], $val['qty']))
 			{
 				continue;
 			}
@@ -393,7 +394,7 @@
 			$this->_cart_contents[$key]['subtotal'] = ($this->_cart_contents[$key]['price'] * $this->_cart_contents[$key]['qty']);
 		}
 
-		// Is our cart empty?  If so we delete it from the session
+		// Is our cart empty? If so we delete it from the session
 		if (count($this->_cart_contents) <= 2)
 		{
 			$this->CI->session->unset_userdata('cart_contents');
@@ -489,7 +490,7 @@
 	 */
 	public function has_options($rowid = '')
 	{
-		return (isset($this->_cart_contents[$rowid]['options']) && count($this->_cart_contents[$rowid]['options']) !== 0) ? TRUE : FALSE;
+		return (isset($this->_cart_contents[$rowid]['options']) && count($this->_cart_contents[$rowid]['options']) !== 0);
 	}
 
 	// --------------------------------------------------------------------
@@ -519,15 +520,7 @@
 	 */
 	public function format_number($n = '')
 	{
-		if ($n == '')
-		{
-			return '';
-		}
-
-		// Remove anything that isn't a number or decimal point.
-		$n = (float) $n;
-
-		return number_format($n, 2, '.', ',');
+		return ($n == '') ? '' : number_format( (float) $n, 2, '.', ',');
 	}
 
 	// --------------------------------------------------------------------
diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php
index b1fff15..c79698c 100644
--- a/system/libraries/Driver.php
+++ b/system/libraries/Driver.php
@@ -45,7 +45,7 @@
 	 * @var array
 	 */
 	protected $valid_drivers = array();
-	
+
 	/**
 	 * Name of the current class - usually the driver class
 	 *
@@ -57,8 +57,8 @@
 	 * The first time a child is used it won't exist, so we instantiate it
 	 * subsequents calls will go straight to the proper child.
 	 *
-	 * @param mixed $child
-	 * @return mixed
+	 * @param	mixed	$child
+	 * @return	mixed
 	 */
 	public function __get($child)
 	{
@@ -145,7 +145,7 @@
 	 * @var array
 	 */
 	protected $_methods = array();
-	
+
 	/**
 	 * List of properties in the parent class
 	 *
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 103c3cb..56d60c8 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -93,6 +93,8 @@
 	 * Constructor - Sets Email Preferences
 	 *
 	 * The constructor can be passed an array of config values
+	 *
+	 * @return	void
 	 */
 	public function __construct($config = array())
 	{
@@ -303,8 +305,7 @@
 	 */
 	public function cc($cc)
 	{
-		$cc = $this->_str_to_array($cc);
-		$cc = $this->clean_email($cc);
+		$cc = $this->clean_email($this->_str_to_array($cc));
 
 		if ($this->validate)
 		{
@@ -338,8 +339,7 @@
 			$this->bcc_batch_size = $limit;
 		}
 
-		$bcc = $this->_str_to_array($bcc);
-		$bcc = $this->clean_email($bcc);
+		$bcc = $this->clean_email($this->_str_to_array($bcc));
 
 		if ($this->validate)
 		{
@@ -441,15 +441,11 @@
 	{
 		if ( ! is_array($email))
 		{
-			if (strpos($email, ',') !== FALSE)
-			{
-				$email = preg_split('/[\s,]/', $email, -1, PREG_SPLIT_NO_EMPTY);
-			}
-			else
-			{
-				$email = (array) trim($email);
-			}
+			return (strpos($email, ',') !== FALSE)
+				? preg_split('/[\s,]/', $email, -1, PREG_SPLIT_NO_EMPTY)
+				: (array) trim($email);
 		}
+
 		return $email;
 	}
 
@@ -477,7 +473,7 @@
 	 */
 	public function set_mailtype($type = 'text')
 	{
-		$this->mailtype = ($type == 'html') ? 'html' : 'text';
+		$this->mailtype = ($type === 'html') ? 'html' : 'text';
 		return $this;
 	}
 
@@ -574,7 +570,7 @@
 	protected function _get_message_id()
 	{
 		$from = str_replace(array('>', '<'), '', $this->_headers['Return-Path']);
-		return  '<'.uniqid('').strstr($from, '@').'>';
+		return '<'.uniqid('').strstr($from, '@').'>';
 	}
 
 	// --------------------------------------------------------------------
@@ -631,13 +627,9 @@
 	 */
 	protected function _get_content_type()
 	{
-		if ($this->mailtype === 'html' && count($this->_attach_name) === 0)
+		if ($this->mailtype === 'html')
 		{
-			return 'html';
-		}
-		elseif	($this->mailtype === 'html' && count($this->_attach_name) > 0)
-		{
-			return 'html-attach';
+			return (count($this->_attach_name) == 0) ? 'html' : 'html-attach';
 		}
 		elseif	($this->mailtype === 'text' && count($this->_attach_name) > 0)
 		{
@@ -731,7 +723,7 @@
 	{
 		if ( ! is_array($email))
 		{
-			return (preg_match('/\<(.*)\>/', $email, $match)) ? $match[1] : $email;
+			return preg_match('/\<(.*)\>/', $email, $match) ? $match[1] : $email;
 		}
 
 		$clean_email = array();
@@ -763,7 +755,7 @@
 			return $this->word_wrap($this->alt_message, '76');
 		}
 
-		$body = (preg_match('/\<body.*?\>(.*)\<\/body\>/si', $this->_body, $match)) ? $match[1] : $this->_body;
+		$body = preg_match('/\<body.*?\>(.*)\<\/body\>/si', $this->_body, $match) ? $match[1] : $this->_body;
 		$body = str_replace("\t", '', preg_replace('#<!--(.*)--\>#', '', trim(strip_tags($body))));
 
 		for ($i = 20; $i >= 3; $i--)
@@ -788,11 +780,11 @@
 		// Se the character limit
 		if ($charlim == '')
 		{
-			$charlim = ($this->wrapchars == "") ? 76 : $this->wrapchars;
+			$charlim = ($this->wrapchars == '') ? 76 : $this->wrapchars;
 		}
 
 		// Reduce multiple spaces
-		$str = preg_replace("| +|", " ", $str);
+		$str = preg_replace('| +|', ' ', $str);
 
 		// Standardize newlines
 		if (strpos($str, "\r") !== FALSE)
@@ -803,22 +795,22 @@
 		// If the current word is surrounded by {unwrap} tags we'll
 		// strip the entire chunk and replace it with a marker.
 		$unwrap = array();
-		if (preg_match_all("|(\{unwrap\}.+?\{/unwrap\})|s", $str, $matches))
+		if (preg_match_all('|(\{unwrap\}.+?\{/unwrap\})|s', $str, $matches))
 		{
 			for ($i = 0, $c = count($matches[0]); $i < $c; $i++)
 			{
 				$unwrap[] = $matches[1][$i];
-				$str = str_replace($matches[1][$i], "{{unwrapped".$i."}}", $str);
+				$str = str_replace($matches[1][$i], '{{unwrapped'.$i.'}}', $str);
 			}
 		}
 
 		// Use PHP's native public function to do the initial wordwrap.
 		// We set the cut flag to FALSE so that any individual words that are
-		// too long get left alone.  In the next step we'll deal with them.
+		// too long get left alone. In the next step we'll deal with them.
 		$str = wordwrap($str, $charlim, "\n", FALSE);
 
 		// Split the string into individual lines of text and cycle through them
-		$output = "";
+		$output = '';
 		foreach (explode("\n", $str) as $line)
 		{
 			// Is the line within the allowed character count?
@@ -833,7 +825,7 @@
 			do
 			{
 				// If the over-length word is a URL we won't wrap it
-				if (preg_match("!\[url.+\]|://|wwww.!", $line))
+				if (preg_match('!\[url.+\]|://|wwww.!', $line))
 				{
 					break;
 				}
@@ -859,7 +851,7 @@
 		{
 			foreach ($unwrap as $key => $val)
 			{
-				$output = str_replace("{{unwrapped".$key."}}", $val, $output);
+				$output = str_replace('{{unwrapped'.$key.'}}', $val, $output);
 			}
 		}
 
@@ -898,15 +890,15 @@
 		}
 
 		reset($this->_headers);
-		$this->_header_str = "";
+		$this->_header_str = '';
 
 		foreach ($this->_headers as $key => $val)
 		{
 			$val = trim($val);
 
-			if ($val != "")
+			if ($val != '')
 			{
-				$this->_header_str .= $key.": ".$val.$this->newline;
+				$this->_header_str .= $key.': '.$val.$this->newline;
 			}
 		}
 
@@ -940,8 +932,8 @@
 		{
 			case 'plain' :
 
-				$hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline
-					. "Content-Transfer-Encoding: " . $this->_get_encoding();
+				$hdr .= 'Content-Type: text/plain; charset='.$this->charset.$this->newline
+					.'Content-Transfer-Encoding: '.$this->_get_encoding();
 
 				if ($this->_get_protocol() === 'mail')
 				{
@@ -959,25 +951,25 @@
 
 				if ($this->send_multipart === FALSE)
 				{
-					$hdr .= "Content-Type: text/html; charset=" . $this->charset . $this->newline
-						. "Content-Transfer-Encoding: quoted-printable";
+					$hdr .= 'Content-Type: text/html; charset='.$this->charset.$this->newline
+						.'Content-Transfer-Encoding: quoted-printable';
 				}
 				else
 				{
-					$hdr .= "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline . $this->newline;
+					$hdr .= 'Content-Type: multipart/alternative; boundary="'.$this->_alt_boundary.'"'.$this->newline.$this->newline;
 
-					$body .= $this->_get_mime_message() . $this->newline . $this->newline
-						. "--" . $this->_alt_boundary . $this->newline
+					$body .= $this->_get_mime_message().$this->newline.$this->newline
+						.'--'.$this->_alt_boundary.$this->newline
 
-						. "Content-Type: text/plain; charset=" . $this->charset . $this->newline
-						. "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline
-						. $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline
+						.'Content-Type: text/plain; charset='.$this->charset.$this->newline
+						.'Content-Transfer-Encoding: '.$this->_get_encoding().$this->newline.$this->newline
+						.$this->_get_alt_message().$this->newline.$this->newline.'--'.$this->_alt_boundary.$this->newline
 
-						. "Content-Type: text/html; charset=" . $this->charset . $this->newline
-						. "Content-Transfer-Encoding: quoted-printable" . $this->newline . $this->newline;
+						.'Content-Type: text/html; charset='.$this->charset.$this->newline
+						.'Content-Transfer-Encoding: quoted-printable'.$this->newline.$this->newline;
 				}
 
-				$this->_finalbody = $body . $this->_prep_quoted_printable($this->_body) . $this->newline . $this->newline;
+				$this->_finalbody = $body.$this->_prep_quoted_printable($this->_body).$this->newline.$this->newline;
 
 
 				if ($this->_get_protocol() === 'mail')
@@ -986,59 +978,59 @@
 				}
 				else
 				{
-					$this->_finalbody = $hdr . $this->_finalbody;
+					$this->_finalbody = $hdr.$this->_finalbody;
 				}
 
 
 				if ($this->send_multipart !== FALSE)
 				{
-					$this->_finalbody .= "--" . $this->_alt_boundary . "--";
+					$this->_finalbody .= '--'.$this->_alt_boundary.'--';
 				}
 
 				return;
 
 			case 'plain-attach' :
 
-				$hdr .= "Content-Type: multipart/".$this->multipart."; boundary=\"" . $this->_atc_boundary."\"" . $this->newline . $this->newline;
+				$hdr .= 'Content-Type: multipart/'.$this->multipart.'; boundary="'.$this->_atc_boundary.'"'.$this->newline.$this->newline;
 
 				if ($this->_get_protocol() === 'mail')
 				{
 					$this->_header_str .= $hdr;
 				}
 
-				$body .= $this->_get_mime_message() . $this->newline . $this->newline
-					. "--" . $this->_atc_boundary . $this->newline
+				$body .= $this->_get_mime_message().$this->newline.$this->newline
+					.'--'.$this->_atc_boundary.$this->newline
 
-					. "Content-Type: text/plain; charset=" . $this->charset . $this->newline
-					. "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline
+					.'Content-Type: text/plain; charset='.$this->charset.$this->newline
+					.'Content-Transfer-Encoding: '.$this->_get_encoding().$this->newline.$this->newline
 
-					. $this->_body . $this->newline . $this->newline;
+					.$this->_body.$this->newline.$this->newline;
 
 			break;
 			case 'html-attach' :
 
-				$hdr .= "Content-Type: multipart/".$this->multipart."; boundary=\"" . $this->_atc_boundary."\"" . $this->newline . $this->newline;
+				$hdr .= 'Content-Type: multipart/'.$this->multipart.'; boundary="'.$this->_atc_boundary.'"'.$this->newline.$this->newline;
 
 				if ($this->_get_protocol() === 'mail')
 				{
 					$this->_header_str .= $hdr;
 				}
 
-				$body .= $this->_get_mime_message() . $this->newline . $this->newline
-					. "--" . $this->_atc_boundary . $this->newline
+				$body .= $this->_get_mime_message().$this->newline.$this->newline
+					.'--'.$this->_atc_boundary.$this->newline
 
-					. "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline .$this->newline
-					. "--" . $this->_alt_boundary . $this->newline
+					.'Content-Type: multipart/alternative; boundary="'.$this->_alt_boundary.'"'.$this->newline.$this->newline
+					.'--'.$this->_alt_boundary.$this->newline
 
-					. "Content-Type: text/plain; charset=" . $this->charset . $this->newline
-					. "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline
-					. $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline
+					.'Content-Type: text/plain; charset='.$this->charset.$this->newline
+					.'Content-Transfer-Encoding: '.$this->_get_encoding().$this->newline.$this->newline
+					.$this->_get_alt_message().$this->newline.$this->newline.'--'.$this->_alt_boundary.$this->newline
 
-					. "Content-Type: text/html; charset=" . $this->charset . $this->newline
-					. "Content-Transfer-Encoding: quoted-printable" . $this->newline . $this->newline
+					.'Content-Type: text/html; charset='.$this->charset.$this->newline
+					.'Content-Transfer-Encoding: quoted-printable'.$this->newline.$this->newline
 
-					. $this->_prep_quoted_printable($this->_body) . $this->newline . $this->newline
-					. "--" . $this->_alt_boundary . "--" . $this->newline . $this->newline;
+					.$this->_prep_quoted_printable($this->_body).$this->newline.$this->newline
+					.'--'.$this->_alt_boundary.'--'.$this->newline.$this->newline;
 
 			break;
 		}
@@ -1047,7 +1039,7 @@
 		for ($i = 0, $c = count($this->_attach_name), $z = 0; $i < $c; $i++)
 		{
 			$filename = $this->_attach_name[$i][0];
-			$basename = (is_null($this->_attach_name[$i][1])) ? basename($filename) : $this->_attach_name[$i][1];
+			$basename = is_null($this->_attach_name[$i][1]) ? basename($filename) : $this->_attach_name[$i][1];
 			$ctype = $this->_attach_type[$i];
 			$file_content = '';
 
@@ -1075,17 +1067,18 @@
 			{
 				$file_content =& $this->_attach_content[$i];
 			}
-			$attachment[$z++] = "--".$this->_atc_boundary.$this->newline
-				. "Content-type: ".$ctype."; "
-				. "name=\"".$basename."\"".$this->newline
-				. "Content-Disposition: ".$this->_attach_disp[$i].";".$this->newline
-				. "Content-Transfer-Encoding: base64".$this->newline;
+
+			$attachment[$z++] = '--'.$this->_atc_boundary.$this->newline
+				.'Content-type: '.$ctype.'; '
+				.'name="'.$basename.'"'.$this->newline
+				.'Content-Disposition: '.$this->_attach_disp[$i].';'.$this->newline
+				.'Content-Transfer-Encoding: base64'.$this->newline;
 
 			$attachment[$z++] = chunk_split(base64_encode($file_content));
 		}
 
-		$body .= implode($this->newline, $attachment).$this->newline."--".$this->_atc_boundary."--";
-		$this->_finalbody = ($this->_get_protocol() === 'mail') ? $body : $hdr . $body;
+		$body .= implode($this->newline, $attachment).$this->newline.'--'.$this->_atc_boundary.'--';
+		$this->_finalbody = ($this->_get_protocol() === 'mail') ? $body : $hdr.$body;
 		return;
 	}
 
@@ -1112,7 +1105,7 @@
 		}
 
 		// Reduce multiple spaces & remove nulls
-		$str = preg_replace(array("| +|", '/\x00+/'), array(' ', ''), $str);
+		$str = preg_replace(array('| +|', '/\x00+/'), array(' ', ''), $str);
 
 		// Standardize newlines
 		if (strpos($str, "\r") !== FALSE)
@@ -1233,11 +1226,9 @@
 			$temp .= $char;
 		}
 
-		$str = $output.$temp;
-
 		// wrap each line with the shebang, charset, and transfer encoding
 		// the preceding space on successive lines is required for header "folding"
-		return trim(preg_replace('/^(.*)$/m', ' =?'.$this->charset.'?Q?$1?=', $str));
+		return trim(preg_replace('/^(.*)$/m', ' =?'.$this->charset.'?Q?$1?=', $output.$temp));
 	}
 
 	// --------------------------------------------------------------------
@@ -1335,7 +1326,7 @@
 	 */
 	protected function _unwrap_specials()
 	{
-		$this->_finalbody = preg_replace_callback("/\{unwrap\}(.*?)\{\/unwrap\}/si", array($this, '_remove_nl_callback'), $this->_finalbody);
+		$this->_finalbody = preg_replace_callback('/\{unwrap\}(.*?)\{\/unwrap\}/si', array($this, '_remove_nl_callback'), $this->_finalbody);
 	}
 
 	// --------------------------------------------------------------------
@@ -1366,10 +1357,10 @@
 	{
 		$this->_unwrap_specials();
 
-		$method = '_send_with_' . $this->_get_protocol();
+		$method = '_send_with_'.$this->_get_protocol();
 		if ( ! $this->$method())
 		{
-			$this->_set_error_message('lang:email_send_failure_' . ($this->_get_protocol() === 'mail' ? 'phpmail' : $this->_get_protocol()));
+			$this->_set_error_message('lang:email_send_failure_'.($this->_get_protocol() === 'mail' ? 'phpmail' : $this->_get_protocol()));
 			return FALSE;
 		}
 
@@ -1394,7 +1385,7 @@
 		{
 			// most documentation of sendmail using the "-f" flag lacks a space after it, however
 			// we've encountered servers that seem to require it to be in place.
-			return mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str, "-f ".$this->clean_email($this->_headers['From']));
+			return mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str, '-f '.$this->clean_email($this->_headers['From']));
 		}
 	}
 
@@ -1407,7 +1398,7 @@
 	 */
 	protected function _send_with_sendmail()
 	{
-		$fp = @popen($this->mailpath . " -oi -f ".$this->clean_email($this->_headers['From'])." -t", 'w');
+		$fp = @popen($this->mailpath.' -oi -f '.$this->clean_email($this->_headers['From']).' -t', 'w');
 
 		if ($fp === FALSE OR $fp === NULL)
 		{
@@ -1461,7 +1452,7 @@
 		{
 			foreach ($this->_cc_array as $val)
 			{
-				if ($val != "")
+				if ($val != '')
 				{
 					$this->_send_command('to', $val);
 				}
@@ -1472,7 +1463,7 @@
 		{
 			foreach ($this->_bcc_array as $val)
 			{
-				if ($val != "")
+				if ($val != '')
 				{
 					$this->_send_command('to', $val);
 				}
@@ -1482,7 +1473,7 @@
 		$this->_send_command('data');
 
 		// perform dot transformation on any lines that begin with a dot
-		$this->_send_data($this->_header_str . preg_replace('/^\./m', '..$1', $this->_finalbody));
+		$this->_send_data($this->_header_str.preg_replace('/^\./m', '..$1', $this->_finalbody));
 
 		$this->_send_data('.');
 
@@ -1513,14 +1504,14 @@
 		$ssl = ($this->smtp_crypto == 'ssl') ? 'ssl://' : NULL;
 
 		$this->_smtp_connect = fsockopen($ssl.$this->smtp_host,
-										$this->smtp_port,
-										$errno,
-										$errstr,
-										$this->smtp_timeout);
+							$this->smtp_port,
+							$errno,
+							$errstr,
+							$this->smtp_timeout);
 
 		if ( ! is_resource($this->_smtp_connect))
 		{
-			$this->_set_error_message('lang:email_smtp_error', $errno." ".$errstr);
+			$this->_set_error_message('lang:email_smtp_error', $errno.' '.$errstr);
 			return FALSE;
 		}
 
@@ -1558,27 +1549,29 @@
 		{
 			case 'hello' :
 
-					if ($this->_smtp_auth OR $this->_get_encoding() == '8bit')
-						$this->_send_data('EHLO '.$this->_get_hostname());
-					else
-						$this->_send_data('HELO '.$this->_get_hostname());
+						if ($this->_smtp_auth OR $this->_get_encoding() === '8bit')
+						{
+							$this->_send_data('EHLO '.$this->_get_hostname());
+						}
+						else
+						{
+							$this->_send_data('HELO '.$this->_get_hostname());
+						}
 
 						$resp = 250;
 			break;
 			case 'starttls'	:
 
 						$this->_send_data('STARTTLS');
-
 						$resp = 220;
 			break;
 			case 'from' :
 
 						$this->_send_data('MAIL FROM:<'.$data.'>');
-
 						$resp = 250;
 			break;
-			case 'to'	:
-						
+			case 'to' :
+
 						if ($this->dsn)
 						{
 							$this->_send_data('RCPT TO:<'.$data.'> NOTIFY=SUCCESS,DELAY,FAILURE ORCPT=rfc822;'.$data);
@@ -1587,25 +1580,24 @@
 						{
 							$this->_send_data('RCPT TO:<'.$data.'>');
 						}
+
 						$resp = 250;
 			break;
 			case 'data'	:
 
 						$this->_send_data('DATA');
-
 						$resp = 354;
 			break;
 			case 'quit'	:
 
 						$this->_send_data('QUIT');
-
 						$resp = 221;
 			break;
 		}
 
 		$reply = $this->_get_smtp_data();
 
-		$this->_debug_msg[] = "<pre>".$cmd.": ".$reply."</pre>";
+		$this->_debug_msg[] = '<pre>'.$cmd.': '.$reply.'</pre>';
 
 		if (substr($reply, 0, 3) != $resp)
 		{
@@ -1701,13 +1693,13 @@
 	 */
 	protected function _get_smtp_data()
 	{
-		$data = "";
+		$data = '';
 
 		while ($str = fgets($this->_smtp_connect, 512))
 		{
 			$data .= $str;
 
-			if ($str[3] == " ")
+			if ($str[3] == ' ')
 			{
 				break;
 			}
@@ -1806,11 +1798,11 @@
 
 		if (substr($msg, 0, 5) !== 'lang:' OR FALSE === ($line = $CI->lang->line(substr($msg, 5))))
 		{
-			$this->_debug_msg[] = str_replace('%s', $val, $msg)."<br />";
+			$this->_debug_msg[] = str_replace('%s', $val, $msg).'<br />';
 		}
 		else
 		{
-			$this->_debug_msg[] = str_replace('%s', $val, $line)."<br />";
+			$this->_debug_msg[] = str_replace('%s', $val, $line).'<br />';
 		}
 	}
 
@@ -1921,4 +1913,4 @@
 }
 
 /* End of file Email.php */
-/* Location: ./system/libraries/Email.php */
+/* Location: ./system/libraries/Email.php */
\ No newline at end of file
diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php
index 17437c1..751557f 100644
--- a/system/libraries/Encrypt.php
+++ b/system/libraries/Encrypt.php
@@ -44,28 +44,28 @@
 	 * @var string
 	 */
 	public $encryption_key		= '';
-	
+
 	/**
 	 * Type of hash operation
-	 * 
+	 *
 	 * @var string
 	 */
 	protected $_hash_type		= 'sha1';
-	
+
 	/**
 	 * Flag for the existance of mcrypt
 	 *
 	 * @var bool
 	 */
 	protected $_mcrypt_exists	= FALSE;
-	
+
 	/**
 	 * Current cipher to be used with mcrypt
 	 *
 	 * @var string
 	 */
 	protected $_mcrypt_cipher;
-	
+
 	/**
 	 * Method for encrypting/decrypting data
 	 *
@@ -75,6 +75,8 @@
 
 	/**
 	 * Initialize Encryption class
+	 *
+	 * @return	void
 	 */
 	public function __construct()
 	{
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index 5547c6a..67cbfd1 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -42,63 +42,63 @@
 	 * @var object
 	 */
 	protected $CI;
-	
+
 	/**
 	 * Validation data for the current form submission
 	 *
 	 * @var array
 	 */
-	protected $_field_data = array();
-	
+	protected $_field_data		= array();
+
 	/**
 	 * Validation rules for the current form
 	 *
 	 * @var array
 	 */
-	protected $_config_rules = array();
-	
+	protected $_config_rules	= array();
+
 	/**
 	 * Array of validation errors
 	 *
 	 * @var array
 	 */
 	protected $_error_array		= array();
-	
+
 	/**
 	 * Array of custom error messages
 	 *
 	 * @var array
 	 */
 	protected $_error_messages	= array();
-	
+
 	/**
 	 * Start tag for error wrapping
 	 *
 	 * @var string
 	 */
 	protected $_error_prefix	= '<p>';
-	
+
 	/**
 	 * End tag for error wrapping
-	 * 
+	 *
 	 * @var string
 	 */
 	protected $_error_suffix	= '</p>';
-	
+
 	/**
 	 * Custom error message
 	 *
 	 * @var string
 	 */
 	protected $error_string		= '';
-	
+
 	/**
 	 * Whether the form data has been validated as safe
 	 *
 	 * @var bool
 	 */
 	protected $_safe_form_data	= FALSE;
-	
+
 	/**
 	 * Custom data to validate
 	 *
@@ -109,7 +109,8 @@
 	/**
 	 * Initialize Form_Validation class
 	 *
-	 * @param array $rules
+	 * @param	array	$rules
+	 * @return	void
 	 */
 	public function __construct($rules = array())
 	{
@@ -222,13 +223,13 @@
 
 		// Build our master array
 		$this->_field_data[$field] = array(
-			'field'				=> $field,
-			'label'				=> $label,
-			'rules'				=> $rules,
-			'is_array'			=> $is_array,
-			'keys'				=> $indexes,
-			'postdata'			=> NULL,
-			'error'				=> ''
+			'field'		=> $field,
+			'label'		=> $label,
+			'rules'		=> $rules,
+			'is_array'	=> $is_array,
+			'keys'		=> $indexes,
+			'postdata'	=> NULL,
+			'error'		=> ''
 		);
 
 		return $this;
@@ -448,7 +449,7 @@
 			{
 				$this->_field_data[$field]['postdata'] = $this->_reduce_array($validation_array, $row['keys']);
 			}
-			elseif ( ! empty($validation_array[$field]))
+			elseif (isset($validation_array[$field]) && $validation_array[$field] !== '')
 			{
 				$this->_field_data[$field]['postdata'] = $validation_array[$field];
 			}
@@ -595,17 +596,14 @@
 				// Set the message type
 				$type = in_array('required', $rules) ? 'required' : 'isset';
 
-				if ( ! isset($this->_error_messages[$type]))
-				{
-					if (FALSE === ($line = $this->CI->lang->line($type)))
-					{
-						$line = 'The field was not set';
-					}
-				}
-				else
+				if (isset($this->_error_messages[$type]))
 				{
 					$line = $this->_error_messages[$type];
 				}
+				elseif (FALSE === ($line = $this->CI->lang->line($type)))
+				{
+					$line = 'The field was not set';
+				}
 
 				// Build the error message
 				$message = sprintf($line, $this->_translate_fieldname($row['label']));
@@ -956,12 +954,8 @@
 	public function matches($str, $field)
 	{
 		$validation_array = empty($this->validation_data) ? $_POST : $this->validation_data;
-		if ( ! isset($validation_array[$field]))
-		{
-			return FALSE;
-		}
 
-		return ($str === $validation_array[$field]);
+		return isset($validation_array[$field]) ? ($str === $validation_array[$field]) : FALSE;
 	}
 
 	// --------------------------------------------------------------------
@@ -1276,7 +1270,7 @@
 	 */
 	public function valid_base64($str)
 	{
-		return (bool) ! preg_match('/[^a-zA-Z0-9\/\+=]/', $str);
+		return ! preg_match('/[^a-zA-Z0-9\/\+=]/', $str);
 	}
 
 	// --------------------------------------------------------------------
diff --git a/system/libraries/Ftp.php b/system/libraries/Ftp.php
index 8aa1650..3cfe1b2 100644
--- a/system/libraries/Ftp.php
+++ b/system/libraries/Ftp.php
@@ -44,7 +44,6 @@
 	public $debug		= FALSE;
 	public $conn_id		= FALSE;
 
-
 	public function __construct($config = array())
 	{
 		if (count($config) > 0)
@@ -539,7 +538,6 @@
 		return FALSE;
 	}
 
-
 	// --------------------------------------------------------------------
 
 	/**
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 2469504..0cb1894 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -38,321 +38,321 @@
 
 	/**
 	 * PHP extension/library to use for image manipulation
-	 * Can be:  imagemagick, netpbm, gd, gd2
+	 * Can be: imagemagick, netpbm, gd, gd2
 	 *
 	 * @var string
 	 */
 	public $image_library		= 'gd2';
-	
+
 	/**
 	 * Path to the graphic library (if applicable)
 	 *
 	 * @var string
 	 */
 	public $library_path		= '';
-	
+
 	/**
 	 * Whether to send to browser or write to disk
 	 *
 	 * @var bool
 	 */
 	public $dynamic_output		= FALSE;
-	
+
 	/**
 	 * Path to original image
 	 *
 	 * @var string
 	 */
 	public $source_image		= '';
-	
+
 	/**
 	 * Path to the modified image
 	 *
 	 * @var string
 	 */
-	public $new_image			= '';
-	
+	public $new_image		= '';
+
 	/**
 	 * Image width
 	 *
 	 * @var int
 	 */
-	public $width				= '';
-	
+	public $width			= '';
+
 	/**
 	 * Image height
 	 *
 	 * @var int
 	 */
-	public $height				= '';
-	
+	public $height			= '';
+
 	/**
 	 * Quality percentage of new image
 	 *
 	 * @var int
 	 */
-	public $quality			= '90';
-	
+	public $quality			= 90;
+
 	/**
 	 * Whether to create a thumbnail
 	 *
 	 * @var bool
 	 */
 	public $create_thumb		= FALSE;
-	
+
 	/**
 	 * String to add to thumbnail version of image
 	 *
 	 * @var string
 	 */
 	public $thumb_marker		= '_thumb';
-	
+
 	/**
 	 * Whether to maintain aspect ratio when resizing or use hard values
 	 *
 	 * @var bool
 	 */
 	public $maintain_ratio		= TRUE;
-	
+
 	/**
 	 * auto, height, or width.  Determines what to use as the master dimension
 	 *
 	 * @var string
 	 */
-	public $master_dim			= 'auto';
-	
+	public $master_dim		= 'auto';
+
 	/**
 	 * Angle at to rotate image
 	 *
 	 * @var string
 	 */
 	public $rotation_angle		= '';
-	
+
 	/**
 	 * X Coordinate for manipulation of the current image
 	 *
 	 * @var int
 	 */
-	public $x_axis				= '';
-	
+	public $x_axis			= '';
+
 	/**
 	 * Y Coordinate for manipulation of the current image
 	 *
 	 * @var int
 	 */
-	public $y_axis				= '';
+	public $y_axis			= '';
 
 	// --------------------------------------------------------------------------
 	// Watermark Vars
 	// --------------------------------------------------------------------------
-	
+
 	/**
 	 * Watermark text if graphic is not used
 	 *
 	 * @var string
 	 */
 	public $wm_text			= '';
-	
+
 	/**
 	 * Type of watermarking.  Options:  text/overlay
 	 *
 	 * @var string
 	 */
 	public $wm_type			= 'text';
-	
+
 	/**
 	 * Default transparency for watermark
-	 * 
+	 *
 	 * @var int
 	 */
 	public $wm_x_transp		= 4;
-	
+
 	/**
 	 * Default transparency for watermark
 	 *
 	 * @var int
 	 */
 	public $wm_y_transp		= 4;
-	
+
 	/**
 	 * Watermark image path
-	 * 
+	 *
 	 * @var string
 	 */
-	public $wm_overlay_path	= '';
-	
+	public $wm_overlay_path		= '';
+
 	/**
 	 * TT font
 	 *
 	 * @var string
 	 */
 	public $wm_font_path		= '';
-	
+
 	/**
 	 * Font size (different versions of GD will either use points or pixels)
 	 *
 	 * @var int
 	 */
 	public $wm_font_size		= 17;
-	
+
 	/**
 	 * Vertical alignment:   T M B
 	 *
 	 * @var string
 	 */
 	public $wm_vrt_alignment	= 'B';
-	
+
 	/**
 	 * Horizontal alignment: L R C
 	 *
 	 * @var string
 	 */
 	public $wm_hor_alignment	= 'C';
-	
+
 	/**
 	 * Padding around text
 	 *
 	 * @var int
 	 */
 	public $wm_padding			= 0;
-	
+
 	/**
 	 * Lets you push text to the right
 	 *
 	 * @var int
 	 */
 	public $wm_hor_offset		= 0;
-	
+
 	/**
 	 * Lets you push text down
 	 *
 	 * @var int
 	 */
 	public $wm_vrt_offset		= 0;
-	
+
 	/**
 	 * Text color
 	 *
 	 * @var string
 	 */
-	protected $wm_font_color		= '#ffffff';
-	
+	protected $wm_font_color	= '#ffffff';
+
 	/**
 	 * Dropshadow color
 	 *
 	 * @var string
 	 */
-	protected $wm_shadow_color		= '';
-	
+	protected $wm_shadow_color	= '';
+
 	/**
 	 * Dropshadow distance
 	 *
 	 * @var int
 	 */
 	public $wm_shadow_distance	= 2;
-	
+
 	/**
 	 * Image opacity: 1 - 100  Only works with image
 	 *
 	 * @var int
 	 */
-	public $wm_opacity			= 50;
+	public $wm_opacity		= 50;
 
 	// --------------------------------------------------------------------------
 	// Private Vars
 	// --------------------------------------------------------------------------
-	
+
 	/**
 	 * Source image folder
 	 *
 	 * @var string
 	 */
 	public $source_folder		= '';
-	
+
 	/**
 	 * Destination image folder
 	 *
 	 * @var string
 	 */
 	public $dest_folder		= '';
-	
+
 	/**
 	 * Image mime-type
 	 *
 	 * @var string
 	 */
-	public $mime_type			= '';
-	
+	public $mime_type		= '';
+
 	/**
-	 * Original image width 
+	 * Original image width
 	 *
 	 * @var int
 	 */
-	public $orig_width			= '';
-	
+	public $orig_width		= '';
+
 	/**
 	 * Original image height
 	 *
 	 * @var int
 	 */
 	public $orig_height		= '';
-	
+
 	/**
 	 * Image format
-	 * 
+	 *
 	 * @var string
 	 */
-	public $image_type			= '';
-	
+	public $image_type		= '';
+
 	/**
 	 * Size of current image
 	 *
 	 * @var string
 	 */
-	public $size_str			= '';
-	
+	public $size_str		= '';
+
 	/**
 	 * Full path to source image
 	 *
 	 * @var string
 	 */
 	public $full_src_path		= '';
-	
+
 	/**
 	 * Full path to destination image
 	 *
 	 * @var string
 	 */
 	public $full_dst_path		= '';
-	
+
 	/**
 	 * Name of function to create image
 	 *
 	 * @var string
 	 */
-	public $create_fnc			= 'imagecreatetruecolor';
-	
+	public $create_fnc		= 'imagecreatetruecolor';
+
 	/**
 	 * Name of function to copy image
 	 *
 	 * @var string
 	 */
-	public $copy_fnc			= 'imagecopyresampled';
-	
+	public $copy_fnc		= 'imagecopyresampled';
+
 	/**
 	 * Error messages
 	 *
 	 * @var array
 	 */
-	public $error_msg			= array();
-	
+	public $error_msg		= array();
+
 	/**
 	 * Whether to have a drop shadow on watermark
 	 *
 	 * @var bool
 	 */
 	protected $wm_use_drop_shadow	= FALSE;
-	
+
 	/**
 	 * Whether to use truetype fonts
 	 *
@@ -364,6 +364,7 @@
 	 * Initialize Image Library
 	 *
 	 * @param	array	$props
+	 * @return	void
 	 */
 	public function __construct($props = array())
 	{
@@ -395,7 +396,7 @@
 
 		$this->image_library 		= 'gd2';
 		$this->dynamic_output 		= FALSE;
-		$this->quality 				= '90';
+		$this->quality 				= 90;
 		$this->create_thumb 		= FALSE;
 		$this->thumb_marker 		= '_thumb';
 		$this->maintain_ratio 		= TRUE;
@@ -895,16 +896,16 @@
 		switch ($this->image_type)
 		{
 			case 1 :
-						$cmd_in		= 'giftopnm';
-						$cmd_out	= 'ppmtogif';
+				$cmd_in		= 'giftopnm';
+				$cmd_out	= 'ppmtogif';
 				break;
 			case 2 :
-						$cmd_in		= 'jpegtopnm';
-						$cmd_out	= 'ppmtojpeg';
+				$cmd_in		= 'jpegtopnm';
+				$cmd_out	= 'ppmtojpeg';
 				break;
 			case 3 :
-						$cmd_in		= 'pngtopnm';
-						$cmd_out	= 'ppmtopng';
+				$cmd_in		= 'pngtopnm';
+				$cmd_out	= 'ppmtopng';
 				break;
 		}
 
@@ -916,15 +917,15 @@
 		{
 			switch ($this->rotation_angle)
 			{
-				case 90		:	$angle = 'r270';
+				case 90:	$angle = 'r270';
 					break;
-				case 180	:	$angle = 'r180';
+				case 180:	$angle = 'r180';
 					break;
-				case 270	:	$angle = 'r90';
+				case 270:	$angle = 'r90';
 					break;
-				case 'vrt'	:	$angle = 'tb';
+				case 'vrt':	$angle = 'tb';
 					break;
-				case 'hor'	:	$angle = 'lr';
+				case 'hor':	$angle = 'lr';
 					break;
 			}
 
@@ -1401,49 +1402,49 @@
 	{
 		switch ($this->image_type)
 		{
-			case 1 :
-						if ( ! function_exists('imagegif'))
-						{
-							$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_gif_not_supported'));
-							return FALSE;
-						}
+			case 1:
+				if ( ! function_exists('imagegif'))
+				{
+					$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_gif_not_supported'));
+					return FALSE;
+				}
 
-						if ( ! @imagegif($resource, $this->full_dst_path))
-						{
-							$this->set_error('imglib_save_failed');
-							return FALSE;
-						}
-				break;
-			case 2	:
-						if ( ! function_exists('imagejpeg'))
-						{
-							$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_jpg_not_supported'));
-							return FALSE;
-						}
+				if ( ! @imagegif($resource, $this->full_dst_path))
+				{
+					$this->set_error('imglib_save_failed');
+					return FALSE;
+				}
+			break;
+			case 2:
+				if ( ! function_exists('imagejpeg'))
+				{
+					$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_jpg_not_supported'));
+					return FALSE;
+				}
 
-						if ( ! @imagejpeg($resource, $this->full_dst_path, $this->quality))
-						{
-							$this->set_error('imglib_save_failed');
-							return FALSE;
-						}
-				break;
-			case 3	:
-						if ( ! function_exists('imagepng'))
-						{
-							$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_png_not_supported'));
-							return FALSE;
-						}
+				if ( ! @imagejpeg($resource, $this->full_dst_path, $this->quality))
+				{
+					$this->set_error('imglib_save_failed');
+					return FALSE;
+				}
+			break;
+			case 3:
+				if ( ! function_exists('imagepng'))
+				{
+					$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_png_not_supported'));
+					return FALSE;
+				}
 
-						if ( ! @imagepng($resource, $this->full_dst_path))
-						{
-							$this->set_error('imglib_save_failed');
-							return FALSE;
-						}
-				break;
-			default		:
-							$this->set_error(array('imglib_unsupported_imagecreate'));
-							return FALSE;
-				break;
+				if ( ! @imagepng($resource, $this->full_dst_path))
+				{
+					$this->set_error('imglib_save_failed');
+					return FALSE;
+				}
+			break;
+			default:
+				$this->set_error(array('imglib_unsupported_imagecreate'));
+				return FALSE;
+			break;
 		}
 
 		return TRUE;
@@ -1466,13 +1467,13 @@
 
 		switch ($this->image_type)
 		{
-			case 1		:	imagegif($resource);
+			case 1	:	imagegif($resource);
 				break;
-			case 2		:	imagejpeg($resource, '', $this->quality);
+			case 2	:	imagejpeg($resource, '', $this->quality);
 				break;
-			case 3		:	imagepng($resource);
+			case 3	:	imagepng($resource);
 				break;
-			default		:	echo 'Unable to display the image';
+			default:	echo 'Unable to display the image';
 				break;
 		}
 	}
@@ -1613,8 +1614,10 @@
 
 		foreach ($allowed as $item)
 		{
-			if ( ! isset($vals[$item]) OR $vals[$item] == '')
+			if (empty($vals[$item]))
+			{
 				$vals[$item] = 0;
+			}
 		}
 
 		if ($vals['width'] == 0 OR $vals['height'] == 0)
@@ -1712,7 +1715,6 @@
 		{
 			foreach ($msg as $val)
 			{
-
 				$msg = ($CI->lang->line($val) == FALSE) ? $val : $CI->lang->line($val);
 				$this->error_msg[] = $msg;
 				log_message('error', $msg);
diff --git a/system/libraries/Log.php b/system/libraries/Log.php
index c10363a..51ce43d 100644
--- a/system/libraries/Log.php
+++ b/system/libraries/Log.php
@@ -42,42 +42,42 @@
 	 * @var string
 	 */
 	protected $_log_path;
-	
+
 	/**
 	 * Level of logging
 	 *
 	 * @var int
 	 */
 	protected $_threshold		= 1;
-	
+
 	/**
 	 * Highest level of logging
 	 *
 	 * @var int
 	 */
 	protected $_threshold_max	= 0;
-	
+
 	/**
 	 * Array of threshold levels to log
 	 *
 	 * @var array
 	 */
 	protected $_threshold_array	= array();
-	
+
 	/**
 	 * Format of timestamp for log files
 	 *
 	 * @var string
 	 */
 	protected $_date_fmt		= 'Y-m-d H:i:s';
-	
+
 	/**
 	 * Whether or not the logger can write to the log files
 	 *
 	 * @var bool
 	 */
 	protected $_enabled		= TRUE;
-	
+
 	/**
 	 * Predefined logging levels
 	 *
@@ -88,7 +88,7 @@
 	/**
 	 * Initialize Logging class
 	 *
-	 * @return void
+	 * @return	void
 	 */
 	public function __construct()
 	{
@@ -151,7 +151,7 @@
 		if ( ! file_exists($filepath))
 		{
 			$newfile = TRUE;
-			$message .= "<"."?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?".">\n\n";
+			$message .= '<'."?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?".">\n\n";
 		}
 
 		if ( ! $fp = @fopen($filepath, FOPEN_WRITE_CREATE))
@@ -159,7 +159,7 @@
 			return FALSE;
 		}
 
-		$message .= $level.' '.(($level == 'INFO') ? ' -' : '-').' '.date($this->_date_fmt). ' --> '.$msg."\n";
+		$message .= $level.' '.($level === 'INFO' ? ' -' : '-').' '.date($this->_date_fmt).' --> '.$msg."\n";
 
 		flock($fp, LOCK_EX);
 		fwrite($fp, $message);
diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php
index ce4683f..0a88e69 100644
--- a/system/libraries/Migration.php
+++ b/system/libraries/Migration.php
@@ -45,28 +45,28 @@
 	 * @var bool
 	 */
 	protected $_migration_enabled = FALSE;
-	
+
 	/**
 	 * Path to migration classes
 	 *
 	 * @var string
 	 */
 	protected $_migration_path = NULL;
-	
+
 	/**
 	 * Current migration version
 	 *
 	 * @var mixed
 	 */
 	protected $_migration_version = 0;
-	
+
 	/**
 	 * Database table with migration info
 	 *
 	 * @var string
 	 */
 	protected $_migration_table = 'migrations';
-	
+
 	/**
 	 * Whether to automatically run migrations
 	 *
@@ -85,6 +85,7 @@
 	 * Initialize Migration Class
 	 *
 	 * @param	array
+	 * @return	void
 	 */
 	public function __construct($config = array())
 	{
@@ -96,7 +97,7 @@
 
 		foreach ($config as $key => $val)
 		{
-			$this->{'_' . $key} = $val;
+			$this->{'_'.$key} = $val;
 		}
 
 		log_message('debug', 'Migrations class initialized');
@@ -340,7 +341,6 @@
 		}
 
 		sort($files);
-
 		return $files;
 	}
 
@@ -384,6 +384,7 @@
 	{
 		return get_instance()->$var;
 	}
+
 }
 
 /* End of file Migration.php */
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index 3d29118..58f86fa 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -73,6 +73,7 @@
 	 * Constructor
 	 *
 	 * @param	array	initialization parameters
+	 * @return	void
 	 */
 	public function __construct($params = array())
 	{
diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php
index c40f339..a0b60ed 100644
--- a/system/libraries/Parser.php
+++ b/system/libraries/Parser.php
@@ -42,14 +42,14 @@
 	 * @var string
 	 */
 	public $l_delim = '{';
-	
+
 	/**
 	 * Right delimeter character for psuedo vars
 	 *
 	 * @var string
 	 */
 	public $r_delim = '}';
-	
+
 	/**
 	 * Reference to CodeIgniter instance
 	 *
@@ -116,14 +116,9 @@
 
 		foreach ($data as $key => $val)
 		{
-			if (is_array($val))
-			{
-				$template = $this->_parse_pair($key, $val, $template);
-			}
-			else
-			{
-				$template = $this->_parse_single($key, (string)$val, $template);
-			}
+			$template = is_array($val)
+					? $this->_parse_pair($key, $val, $template)
+					: $template = $this->_parse_single($key, (string) $val, $template);
 		}
 
 		if ($return == FALSE)
@@ -189,14 +184,9 @@
 			$temp = $match[1];
 			foreach ($row as $key => $val)
 			{
-				if ( ! is_array($val))
-				{
-					$temp = $this->_parse_single($key, $val, $temp);
-				}
-				else
-				{
-					$temp = $this->_parse_pair($key, $val, $temp);
-				}
+				$temp = is_array($val)
+						? $this->_parse_pair($key, $val, $temp)
+						: $this->_parse_single($key, $val, $temp);
 			}
 
 			$str .= $temp;
diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php
index 1e86f3c..e219d20 100644
--- a/system/libraries/Profiler.php
+++ b/system/libraries/Profiler.php
@@ -527,6 +527,7 @@
 
 		return $output.'</div>';
 	}
+
 }
 
 /* End of file Profiler.php */
diff --git a/system/libraries/Session.php b/system/libraries/Session.php
index 3fa446d..783109a 100644
--- a/system/libraries/Session.php
+++ b/system/libraries/Session.php
@@ -36,146 +36,146 @@
  */
 class CI_Session {
 
-	/** 
+	/**
 	 * Whether to encrypt the session cookie
 	 *
 	 * @var bool
 	 */
 	public $sess_encrypt_cookie		= FALSE;
-	
+
 	/**
 	 * Whether to use to the database for session storage
 	 *
 	 * @var bool
 	 */
 	public $sess_use_database		= FALSE;
-	
+
 	/**
 	 * Name of the database table in which to store sessions
 	 *
 	 * @var string
 	 */
 	public $sess_table_name			= '';
-	
+
 	/**
 	 * Length of time (in seconds) for sessions to expire
 	 *
 	 * @var int
 	 */
 	public $sess_expiration			= 7200;
-	
+
 	/**
 	 * Whether to kill session on close of browser window
 	 *
 	 * @var bool
 	 */
 	public $sess_expire_on_close		= FALSE;
-	
+
 	/**
 	 * Whether to match session on ip address
 	 *
 	 * @var bool
 	 */
 	public $sess_match_ip			= FALSE;
-	
+
 	/**
 	 * Whether to match session on user-agent
 	 *
 	 * @var bool
 	 */
 	public $sess_match_useragent		= TRUE;
-	
+
 	/**
 	 * Name of session cookie
 	 *
 	 * @var string
 	 */
 	public $sess_cookie_name		= 'ci_session';
-	
+
 	/**
 	 * Session cookie prefix
 	 *
 	 * @var string
 	 */
 	public $cookie_prefix			= '';
-	
+
 	/**
 	 * Session cookie path
 	 *
 	 * @var string
 	 */
 	public $cookie_path			= '';
-	
+
 	/**
 	 * Session cookie domain
 	 *
 	 * @var string
 	 */
 	public $cookie_domain			= '';
-	
+
 	/**
 	 * Whether to set the cookie only on HTTPS connections
 	 *
 	 * @var bool
 	 */
 	public $cookie_secure			= FALSE;
-	
+
 	/**
 	 * Whether cookie should be allowed only to be sent by the server
 	 *
 	 * @var bool
 	 */
 	public $cookie_httponly 		= FALSE;
-	
+
 	/**
 	 * Interval at which to update session
 	 *
 	 * @var int
 	 */
 	public $sess_time_to_update		= 300;
-	
+
 	/**
 	 * Key with which to encrypt the session cookie
 	 *
 	 * @var string
 	 */
 	public $encryption_key			= '';
-	
+
 	/**
 	 * String to indicate flash data cookies
 	 *
 	 * @var string
 	 */
 	public $flashdata_key			= 'flash';
-	
+
 	/**
 	 * Function to use to get the current time
 	 *
 	 * @var string
 	 */
 	public $time_reference			= 'time';
-	
+
 	/**
 	 * Probablity level of garbage collection of old sessions
 	 *
 	 * @var int
 	 */
 	public $gc_probability			= 5;
-	
+
 	/**
 	 * Session data
 	 *
 	 * @var array
 	 */
 	public $userdata			= array();
-	
+
 	/**
 	 * Reference to CodeIgniter instance
 	 *
 	 * @var object
 	 */
 	public $CI;
-	
+
 	/**
 	 * Current time
 	 *
@@ -190,6 +190,7 @@
 	 * whenever the class is instantiated.
 	 *
 	 * @param	array
+	 * @return	void
 	 */
 	public function __construct($params = array())
 	{
@@ -570,6 +571,9 @@
 				$this->cookie_domain,
 				0
 			);
+
+		// Kill session data
+		$this->userdata = array();
 	}
 
 	// --------------------------------------------------------------------
diff --git a/system/libraries/Table.php b/system/libraries/Table.php
index 2361295..f844d64 100644
--- a/system/libraries/Table.php
+++ b/system/libraries/Table.php
@@ -44,49 +44,49 @@
 	 * @var array
 	 */
 	public $rows		= array();
-	
+
 	/**
 	 * Data for table heading
 	 *
 	 * @var array
 	 */
 	public $heading		= array();
-	
+
 	/**
 	 * Whether or not to automatically create the table header
 	 *
 	 * @var bool
 	 */
 	public $auto_heading	= TRUE;
-	
+
 	/**
 	 * Table caption
 	 *
 	 * @var string
 	 */
 	public $caption		= NULL;
-	
+
 	/**
-	 * Table layout template 
+	 * Table layout template
 	 *
 	 * @var array
 	 */
 	public $template	= NULL;
-	
+
 	/**
 	 * Newline setting
 	 *
 	 * @var string
 	 */
 	public $newline		= "\n";
-	
+
 	/**
 	 * Contents of empty cells
 	 *
 	 * @var string
 	 */
 	public $empty_cells	= '';
-	
+
 	/**
 	 * Callback for custom table layout
 	 *
diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php
index 50bd124..6aaa993 100644
--- a/system/libraries/Typography.php
+++ b/system/libraries/Typography.php
@@ -38,7 +38,7 @@
 
 	/**
 	 * Block level elements that should not be wrapped inside <p> tags
-	 * 
+	 *
 	 * @var string
 	 */
 	public $block_elements = 'address|blockquote|div|dl|fieldset|form|h\d|hr|noscript|object|ol|p|pre|script|table|ul';
@@ -52,7 +52,7 @@
 
 	/**
 	 * Tags we want the parser to completely ignore when splitting the string.
-	 * 
+	 *
 	 * @var string
 	 */
 	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';
diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php
index 0f6e2df..6ec2dcd 100644
--- a/system/libraries/Unit_test.php
+++ b/system/libraries/Unit_test.php
@@ -350,11 +350,11 @@
  */
 function is_true($test)
 {
-	return (is_bool($test) && $test === TRUE);
+	return ($test === TRUE);
 }
 function is_false($test)
 {
-	return (is_bool($test) && $test === FALSE);
+	return ($test === FALSE);
 }
 
 /* End of file Unit_test.php */
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 8ad6705..271c6d2 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -725,7 +725,7 @@
 	public function get_extension($filename)
 	{
 		$x = explode('.', $filename);
-		return '.'.end($x);
+		return (count($x) !== 1) ? '.'.end($x) : '';
 	}
 
 	// --------------------------------------------------------------------
@@ -850,6 +850,10 @@
 			{
 				return TRUE; // its an image, no "triggers" detected in the first 256 bytes, we're good
 			}
+			else
+			{
+				return FALSE;
+			}
 		}
 
 		if (($data = @file_get_contents($file)) === FALSE)
@@ -1032,7 +1036,7 @@
 		 */
 		if (DIRECTORY_SEPARATOR !== '\\')
 		{
-			$cmd = 'file --brief --mime ' . escapeshellarg($file['tmp_name']) . ' 2>&1';
+			$cmd = 'file --brief --mime '.escapeshellarg($file['tmp_name']).' 2>&1';
 
 			if (function_exists('exec'))
 			{
diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php
index 0ac605f..ff596f0 100644
--- a/system/libraries/User_agent.php
+++ b/system/libraries/User_agent.php
@@ -51,14 +51,14 @@
 	 * @var bool
 	 */
 	public $is_browser = FALSE;
-	
+
 	/**
 	 * Flag for if the user-agent is a robot
 	 *
 	 * @var bool
 	 */
 	public $is_robot = FALSE;
-	
+
 	/**
 	 * Flag for if the user-agent is a mobile browser
 	 *
@@ -72,7 +72,7 @@
 	 * @var array
 	 */
 	public $languages = array();
-	
+
 	/**
 	 * Character sets accepted by the current user agent
 	 *
@@ -86,21 +86,21 @@
 	 * @var array
 	 */
 	public $platforms = array();
-	
+
 	/**
 	 * List of browsers to compare against current user agent
 	 *
 	 * @var array
 	 */
 	public $browsers = array();
-	
+
 	/**
 	 * List of mobile browsers to compare against current user agent
 	 *
 	 * @var array
 	 */
 	public $mobiles = array();
-	
+
 	/**
 	 * List of robots to compare against current user agent
 	 *
@@ -114,28 +114,28 @@
 	 * @var string
 	 */
 	public $platform = '';
-	
+
 	/**
 	 * Current user-agent browser
 	 *
 	 * @var string
 	 */
 	public $browser = '';
-	
+
 	/**
 	 * Current user-agent version
 	 *
 	 * @var string
 	 */
 	public $version = '';
-	
+
 	/**
 	 * Current user-agent mobile name
 	 *
 	 * @var string
 	 */
 	public $mobile = '';
-	
+
 	/**
 	 * Current user-agent robot name
 	 *
@@ -330,7 +330,7 @@
 		{
 			foreach ($this->mobiles as $key => $val)
 			{
-				if (FALSE !== (strpos(strtolower($this->agent), $key)))
+				if (FALSE !== (stripos($this->agent, $key)))
 				{
 					$this->is_mobile = TRUE;
 					$this->mobile = $val;
@@ -604,7 +604,7 @@
 	/**
 	 * Test for a particular character set
 	 *
-	 * @param	string $charset
+	 * @param	string	$charset
 	 * @return	bool
 	 */
 	public function accept_charset($charset = 'utf-8')
diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php
index f0c5b48..1853906 100644
--- a/system/libraries/Xmlrpcs.php
+++ b/system/libraries/Xmlrpcs.php
@@ -54,21 +54,21 @@
 	 * @var array
 	 */
 	public $methods = array();
-	
+
 	/**
 	 * Debug Message
 	 *
 	 * @var string
 	 */
 	public $debug_msg = '';
-	
+
 	/**
 	 * XML RPC Server methods
 	 *
 	 * @var array
 	 */
 	public $system_methods	= array();
-	
+
 	/**
 	 * Configuration object
 	 *
@@ -79,7 +79,8 @@
 	/**
 	 * Initialize XMLRPC class
 	 *
-	 * @param array $config
+	 * @param	array	$config
+	 * @return	void
 	 */
 	public function __construct($config = array())
 	{
diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php
index 86d0787..e0dc637 100644
--- a/system/libraries/Zip.php
+++ b/system/libraries/Zip.php
@@ -48,35 +48,35 @@
 	 * @var string
 	 */
 	public $zipdata		= '';
-	
+
 	/**
 	 * Zip data for a directory in string form
 	 *
 	 * @var string
 	 */
 	public $directory	= '';
-	
+
 	/**
 	 * Number of files/folder in zip file
 	 *
 	 * @var int
 	 */
 	public $entries		= 0;
-	
+
 	/**
 	 * Number of files in zip
 	 *
 	 * @var int
 	 */
 	public $file_num	= 0;
-	
+
 	/**
 	 * relative offset of local header
 	 *
 	 * @var int
 	 */
 	public $offset		= 0;
-	
+
 	/**
 	 * Reference to time at init
 	 *
@@ -87,7 +87,7 @@
 	/**
 	 * Initialize zip compression class
 	 *
-	 * @return void
+	 * @return	void
 	 */
 	public function __construct()
 	{
diff --git a/system/libraries/javascript/Jquery.php b/system/libraries/javascript/Jquery.php
index f30d7c6..3c9ae18 100644
--- a/system/libraries/javascript/Jquery.php
+++ b/system/libraries/javascript/Jquery.php
@@ -25,8 +25,6 @@
  * @filesource
  */
 
-// ------------------------------------------------------------------------
-
 /**
  * Jquery Class
  *
@@ -57,7 +55,7 @@
 			$this->script();
 		}
 
-		log_message('debug', "Jquery Class Initialized");
+		log_message('debug', 'Jquery Class Initialized');
 	}
 
 	// --------------------------------------------------------------------
@@ -115,7 +113,7 @@
 
 		if ($ret_false)
 		{
-			$js[] = "return false;";
+			$js[] = 'return false;';
 		}
 
 		return $this->_add_event($element, $js, 'click');
@@ -183,7 +181,7 @@
 	 */
 	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";
+		$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";
 
 		$this->jquery_code_for_compile[] = $event;
 
@@ -322,7 +320,7 @@
 
 		foreach ($array_js as $js)
 		{
-			$this->jquery_code_for_compile[] = "\t$js\n";
+			$this->jquery_code_for_compile[] = "\t".$js."\n";
 		}
 	}
 
@@ -389,7 +387,7 @@
 	protected function _addClass($element = 'this', $class='')
 	{
 		$element = $this->_prep_element($element);
-		return "$({$element}).addClass(\"$class\");";
+		return '$('.$element.').addClass("'.$class.'");';
 	}
 
 	// --------------------------------------------------------------------
@@ -411,9 +409,9 @@
 
 		$animations = "\t\t\t";
 
-		foreach ($params as $param=>$value)
+		foreach ($params as $param => $value)
 		{
-			$animations .= $param.': \''.$value.'\', ';
+			$animations .= $param.": '".$value."', ";
 		}
 
 		$animations = substr($animations, 0, -2); // remove the last ", "
@@ -428,7 +426,7 @@
 			$extra = ', '.$extra;
 		}
 
-		return "$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.");";
+		return "$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.');';
 	}
 
 	// --------------------------------------------------------------------
@@ -478,7 +476,7 @@
 			$callback = ", function(){\n{$callback}\n}";
 		}
 
-		return "$({$element}).fadeOut({$speed}{$callback});";
+		return '$('.$element.').fadeOut('.$speed.$callback.');';
 	}
 
 	// --------------------------------------------------------------------
@@ -519,7 +517,7 @@
 	protected function _removeClass($element = 'this', $class='')
 	{
 		$element = $this->_prep_element($element);
-		return "$({$element}).removeClass(\"$class\");";
+		return '$('.$element.').removeClass("'.$class.'");';
 	}
 
 	// --------------------------------------------------------------------
@@ -544,7 +542,7 @@
 			$callback = ", function(){\n{$callback}\n}";
 		}
 
-		return "$({$element}).slideUp({$speed}{$callback});";
+		return '$('.$element.').slideUp('.$speed.$callback.');';
 	}
 
 	// --------------------------------------------------------------------
@@ -569,7 +567,7 @@
 			$callback = ", function(){\n{$callback}\n}";
 		}
 
-		return "$({$element}).slideDown({$speed}{$callback});";
+		return '$('.$element.').slideDown('.$speed.$callback.');';
 	}
 
 	// --------------------------------------------------------------------
@@ -594,7 +592,7 @@
 			$callback = ", function(){\n{$callback}\n}";
 		}
 
-		return "$({$element}).slideToggle({$speed}{$callback});";
+		return '$('.$element.').slideToggle('.$speed.$callback.');';
 	}
 
 	// --------------------------------------------------------------------
@@ -610,7 +608,7 @@
 	protected function _toggle($element = 'this')
 	{
 		$element = $this->_prep_element($element);
-		return "$({$element}).toggle();";
+		return '$('.$element.').toggle();';
 	}
 
 	// --------------------------------------------------------------------
@@ -626,7 +624,7 @@
 	protected function _toggleClass($element = 'this', $class='')
 	{
 		$element = $this->_prep_element($element);
-		return "$({$element}).toggleClass(\"$class\");";
+		return '$('.$element.').toggleClass("'.$class.'");';
 	}
 
 	// --------------------------------------------------------------------
@@ -651,7 +649,7 @@
 			$callback = ", function(){\n{$callback}\n}";
 		}
 
-		return "$({$element}).show({$speed}{$callback});";
+		return '$('.$element.').show('.$speed.$callback.');';
 	}
 
 	// --------------------------------------------------------------------
@@ -676,22 +674,22 @@
 		// ajaxStart and ajaxStop are better choices here... but this is a stop gap
 		if ($this->CI->config->item('javascript_ajax_img') == '')
 		{
-			$loading_notifier = "Loading...";
+			$loading_notifier = 'Loading...';
 		}
 		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
-			. "\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 .= ', {'
-					. (is_array($options) ? "'".implode("', '", $options)."'" : "'".str_replace(":", "':'", $options)."'")
-					. '}';
+					.(is_array($options) ? "'".implode("', '", $options)."'" : "'".str_replace(':', "':'", $options)."'")
+					.'}';
 		}
 
 		return $updater."\t\t$($container).load('$controller'$request_options);";
@@ -746,7 +744,7 @@
 			$corner_style = '"'.$corner_style.'"';
 		}
 
-		return "$(" . $this->_prep_element($element) . ").corner(".$corner_style.");";
+		return '$('.$this->_prep_element($element).').corner('.$corner_style.');';
 	}
 
 	// --------------------------------------------------------------------
@@ -821,16 +819,16 @@
 			$sort_options = array();
 			foreach ($options as $k=>$v)
 			{
-				$sort_options[] = "\n\t\t".$k.': '.$v."";
+				$sort_options[] = "\n\t\t".$k.': '.$v;
 			}
-			$sort_options = implode(",", $sort_options);
+			$sort_options = implode(',', $sort_options);
 		}
 		else
 		{
 			$sort_options = '';
 		}
 
-		return "$(" . $this->_prep_element($element) . ").sortable({".$sort_options."\n\t});";
+		return '$('.$this->_prep_element($element).').sortable({'.$sort_options."\n\t});";
 	}
 
 	// --------------------------------------------------------------------
@@ -844,7 +842,7 @@
 	 */
 	public function tablesorter($table = '', $options = '')
 	{
-		$this->jquery_code_for_compile[] = "\t$(" . $this->_prep_element($table) . ").tablesorter($options);\n";
+		$this->jquery_code_for_compile[] = "\t$(".$this->_prep_element($table).').tablesorter('.$options.");\n";
 	}
 
 	// --------------------------------------------------------------------
@@ -869,7 +867,7 @@
 
 		}
 
-		$event = "\n\t$(" . $this->_prep_element($element) . ").{$event}(function(){\n\t\t{$js}\n\t});\n";
+		$event = "\n\t$(".$this->_prep_element($element).').'.$event."(function(){\n\t\t{$js}\n\t});\n";
 		$this->jquery_code_for_compile[] = $event;
 		return $event;
 	}
@@ -898,8 +896,8 @@
 
 		// Inline references
 		$script = '$(document).ready(function() {'."\n"
-			. implode('', $this->jquery_code_for_compile)
-			. '});';
+			.implode('', $this->jquery_code_for_compile)
+			.'});';
 
 		$output = ($script_tags === FALSE) ? $script : $this->inline($script);
 
@@ -998,7 +996,7 @@
 		{
 			return '"'.$speed.'"';
 		}
-		elseif (preg_match("/[^0-9]/", $speed))
+		elseif (preg_match('/[^0-9]/', $speed))
 		{
 			return '';
 		}
@@ -1009,4 +1007,4 @@
 }
 
 /* End of file Jquery.php */
-/* Location: ./system/libraries/Jquery.php */
+/* Location: ./system/libraries/Jquery.php */
\ No newline at end of file
diff --git a/tests/README.md b/tests/README.md
index 6d83c34..c8fc608 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -1,12 +1,6 @@
 # CodeIgniter Unit Tests #
 
-Status : [![Build Status](https://secure.travis-ci.org/EllisLab/CodeIgniter.png?branch=feature/unit-tests)](http://travis-ci.org/EllisLab/CodeIgniter)
-
-*Do not merge to default until these issues have been addressed*
-
-- Clean up naming conventions
-- Figure out config stuff
-- Figure out database testing
+Status : [![Build Status](https://secure.travis-ci.org/EllisLab/CodeIgniter.png?branch=develop)](http://travis-ci.org/EllisLab/CodeIgniter)
 
 ### Introduction:
 
diff --git a/tests/codeigniter/Setup_test.php b/tests/codeigniter/Setup_test.php
index 550245f..b48e32b 100644
--- a/tests/codeigniter/Setup_test.php
+++ b/tests/codeigniter/Setup_test.php
@@ -2,12 +2,12 @@
 
 class Setup_test extends PHPUnit_Framework_TestCase {
 	
-	function test_nonsense()
+	function test_bootstrap_constants()
 	{
-		$this->markTestIncomplete('not implemented');
-		// ensure that our bootstrapped test environment
-		// is a good representation of an isolated CI install
-		//die('here');
+		$this->assertTrue(defined('PROJECT_BASE'));
+		$this->assertTrue(defined('BASEPATH'));
+		$this->assertTrue(defined('APPPATH'));
+		$this->assertTrue(defined('VIEWPATH'));
 	}
 	
 }
\ No newline at end of file
diff --git a/tests/codeigniter/core/Benchmark_test.php b/tests/codeigniter/core/Benchmark_test.php
new file mode 100644
index 0000000..109b388
--- /dev/null
+++ b/tests/codeigniter/core/Benchmark_test.php
@@ -0,0 +1,42 @@
+<?php
+
+class Benchmark_test extends CI_TestCase {
+	
+	public function set_up()
+	{
+		$this->benchmark = new Mock_Core_Benchmark();
+	}
+	
+	// --------------------------------------------------------------------
+	
+	public function test_mark()
+	{
+		$this->assertEmpty($this->benchmark->marker);
+
+		$this->benchmark->mark('code_start');
+
+		$this->assertEquals(1, count($this->benchmark->marker));
+		$this->assertArrayHasKey('code_start', $this->benchmark->marker);
+	}
+	
+	// --------------------------------------------------------------------
+
+	public function test_elapsed_time()
+	{
+		$this->assertEquals('{elapsed_time}', $this->benchmark->elapsed_time());
+		$this->assertEmpty($this->benchmark->elapsed_time('undefined_point'));
+
+		$this->benchmark->mark('code_start');
+		sleep(1);
+		$this->benchmark->mark('code_end');
+		
+		$this->assertEquals('1.0', $this->benchmark->elapsed_time('code_start', 'code_end', 1));
+	}
+
+	// --------------------------------------------------------------------
+
+	public function test_memory_usage()
+	{
+		$this->assertEquals('{memory_usage}', $this->benchmark->memory_usage());
+	}
+}
\ No newline at end of file
diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php
new file mode 100644
index 0000000..fd0576e
--- /dev/null
+++ b/tests/codeigniter/core/Input_test.php
@@ -0,0 +1,144 @@
+<?php
+
+class Input_test extends CI_TestCase {
+	
+	public function set_up()
+	{
+		// Set server variable to GET as default, since this will leave unset in STDIN env
+		$_SERVER['REQUEST_METHOD'] = 'GET';
+
+		// Set config for Input class
+		$this->ci_set_config('allow_get_array',	TRUE);
+		$this->ci_set_config('global_xss_filtering', FALSE);
+		$this->ci_set_config('csrf_protection', FALSE);
+
+		$security = new Mock_Core_Security();
+		$utf8 = new Mock_Core_Utf8();
+
+		$this->input = new Mock_Core_Input($security, $utf8);
+	}
+	
+	// --------------------------------------------------------------------
+	
+	public function test_get_not_exists()
+	{
+		$this->assertEmpty($this->input->get());
+		$this->assertEmpty($this->input->get('foo'));
+
+		$this->assertTrue( ! $this->input->get());
+		$this->assertTrue( ! $this->input->get('foo'));
+
+		$this->assertTrue($this->input->get() == FALSE);
+		$this->assertTrue($this->input->get('foo') == FALSE);
+
+		$this->assertTrue($this->input->get() === FALSE);
+		$this->assertTrue($this->input->get('foo') === FALSE);
+	}
+
+	// --------------------------------------------------------------------
+	
+	public function test_get_exist()
+	{
+		$_SERVER['REQUEST_METHOD'] = 'GET';
+		$_GET['foo'] = 'bar';
+
+		$this->assertArrayHasKey('foo', $this->input->get());
+		$this->assertEquals('bar', $this->input->get('foo'));
+	}
+
+	// --------------------------------------------------------------------
+	
+	public function test_get_exist_with_xss_clean()
+	{
+		$_SERVER['REQUEST_METHOD'] = 'GET';
+		$_GET['harm'] = "Hello, i try to <script>alert('Hack');</script> your site";
+
+		$this->assertArrayHasKey('harm', $this->input->get());
+		$this->assertEquals("Hello, i try to <script>alert('Hack');</script> your site", $this->input->get('harm'));
+		$this->assertEquals("Hello, i try to [removed]alert&#40;'Hack'&#41;;[removed] your site", $this->input->get('harm', TRUE));
+	}
+
+	// --------------------------------------------------------------------
+	
+	public function test_post_not_exists()
+	{
+		$this->assertEmpty($this->input->post());
+		$this->assertEmpty($this->input->post('foo'));
+
+		$this->assertTrue( ! $this->input->post());
+		$this->assertTrue( ! $this->input->post('foo'));
+
+		$this->assertTrue($this->input->post() == FALSE);
+		$this->assertTrue($this->input->post('foo') == FALSE);
+
+		$this->assertTrue($this->input->post() === FALSE);
+		$this->assertTrue($this->input->post('foo') === FALSE);
+	}
+
+	// --------------------------------------------------------------------
+	
+	public function test_post_exist()
+	{
+		$_SERVER['REQUEST_METHOD'] = 'POST';
+		$_POST['foo'] = 'bar';
+
+		$this->assertArrayHasKey('foo', $this->input->post());
+		$this->assertEquals('bar', $this->input->post('foo'));
+	}
+
+	// --------------------------------------------------------------------
+	
+	public function test_post_exist_with_xss_clean()
+	{
+		$_SERVER['REQUEST_METHOD'] = 'POST';
+		$_POST['harm'] = "Hello, i try to <script>alert('Hack');</script> your site";
+
+		$this->assertArrayHasKey('harm', $this->input->post());
+		$this->assertEquals("Hello, i try to <script>alert('Hack');</script> your site", $this->input->post('harm'));
+		$this->assertEquals("Hello, i try to [removed]alert&#40;'Hack'&#41;;[removed] your site", $this->input->post('harm', TRUE));
+	}
+
+	// --------------------------------------------------------------------
+	
+	public function test_get_post()
+	{
+		$_SERVER['REQUEST_METHOD'] = 'POST';
+		$_POST['foo'] = 'bar';
+
+		$this->assertEquals('bar', $this->input->get_post('foo'));
+	}
+
+	// --------------------------------------------------------------------
+	
+	public function test_cookie()
+	{
+		$_COOKIE['foo'] = 'bar';
+
+		$this->assertEquals('bar', $this->input->cookie('foo'));
+	}
+
+	// --------------------------------------------------------------------
+	
+	public function test_server()
+	{
+		$this->assertEquals('GET', $this->input->server('REQUEST_METHOD'));
+	}
+
+	// --------------------------------------------------------------------
+	
+	public function test_fetch_from_array()
+	{
+		$data = array(
+			'foo' => 'bar',
+			'harm' => 'Hello, i try to <script>alert(\'Hack\');</script> your site',
+		);
+
+		$foo = $this->input->fetch_from_array($data, 'foo');
+		$harm = $this->input->fetch_from_array($data, 'harm');
+		$harmless = $this->input->fetch_from_array($data, 'harm', TRUE);
+
+		$this->assertEquals('bar', $foo);
+		$this->assertEquals("Hello, i try to <script>alert('Hack');</script> your site", $harm);
+		$this->assertEquals("Hello, i try to [removed]alert&#40;'Hack'&#41;;[removed] your site", $harmless);
+	}
+}
\ No newline at end of file
diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php
new file mode 100644
index 0000000..1796ba7
--- /dev/null
+++ b/tests/codeigniter/core/Security_test.php
@@ -0,0 +1,73 @@
+<?php
+
+class Security_test extends CI_TestCase {
+	
+	public function set_up()
+	{
+		// Set cookie for security test
+		$_COOKIE['ci_csrf_cookie'] = md5(uniqid(rand(), TRUE));
+
+		// Set config for Security class
+		$this->ci_set_config('csrf_protection', TRUE);
+		$this->ci_set_config('csrf_token_name', 'ci_csrf_token');
+		$this->ci_set_config('csrf_cookie_name', 'ci_csrf_cookie');
+
+		$this->security = new Mock_Core_Security();
+	}
+	
+	// --------------------------------------------------------------------
+	
+	public function test_csrf_verify()
+	{
+		$_SERVER['REQUEST_METHOD'] = 'GET';
+
+		$this->assertInstanceOf('CI_Security', $this->security->csrf_verify());
+	}
+
+	// --------------------------------------------------------------------
+	
+	public function test_csrf_verify_invalid()
+	{
+		// Without issuing $_POST[csrf_token_name], this request will triggering CSRF error
+		$_SERVER['REQUEST_METHOD'] = 'POST';
+
+		$this->setExpectedException('RuntimeException', 'CI Error: The action you have requested is not allowed');
+
+		$this->security->csrf_verify();
+	}
+
+	// --------------------------------------------------------------------
+	
+	public function test_csrf_verify_valid()
+	{
+		$_SERVER['REQUEST_METHOD'] = 'POST';
+		$_POST[$this->security->csrf_token_name] = $this->security->csrf_hash;
+
+		$this->assertInstanceOf('CI_Security', $this->security->csrf_verify());
+	}
+
+	// --------------------------------------------------------------------
+	
+	public function test_get_csrf_hash()
+	{
+		$this->assertEquals($this->security->csrf_hash, $this->security->get_csrf_hash());
+	}
+
+	// --------------------------------------------------------------------
+	
+	public function test_get_csrf_token_name()
+	{
+		$this->assertEquals('ci_csrf_token', $this->security->get_csrf_token_name());
+	}
+
+	// --------------------------------------------------------------------
+	
+	public function test_xss_clean()
+	{
+		$harm_string = "Hello, i try to <script>alert('Hack');</script> your site";
+
+		$harmless_string = $this->security->xss_clean($harm_string);
+
+		$this->assertEquals("Hello, i try to [removed]alert&#40;'Hack'&#41;;[removed] your site", $harmless_string);
+	}
+}
\ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/count_test.php b/tests/codeigniter/database/query_builder/count_test.php
new file mode 100644
index 0000000..5e69169
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/count_test.php
@@ -0,0 +1,44 @@
+<?php
+
+class Count_test extends CI_TestCase {
+
+	/**
+	 * @var object Database/Query Builder holder
+	 */
+	protected $db;
+
+	public function set_up()
+	{
+		$this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+		Mock_Database_Schema_Skeleton::create_tables();
+		Mock_Database_Schema_Skeleton::create_data();
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_count_all()
+	{
+		$job_count = $this->db->count_all('job');
+		
+		// Check the result
+		$this->assertEquals(4, $job_count);
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_count_all_results()
+	{
+		$job_count = $this->db->like('name', 'ian')
+		                      ->count_all_results('job');
+		
+		// Check the result
+		$this->assertEquals(2, $job_count);
+	}
+}
\ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/delete_test.php b/tests/codeigniter/database/query_builder/delete_test.php
new file mode 100644
index 0000000..84ea761
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/delete_test.php
@@ -0,0 +1,72 @@
+<?php
+
+class Delete_test extends CI_TestCase {
+
+	/**
+	 * @var object Database/Query Builder holder
+	 */
+	protected $db;
+
+	public function set_up()
+	{
+		$this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+		Mock_Database_Schema_Skeleton::create_tables();
+		Mock_Database_Schema_Skeleton::create_data();
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_delete()
+	{
+		// Check initial record
+		$job1 = $this->db->where('id', 1)
+							->get('job')
+							->row();
+
+		$this->assertEquals('Developer', $job1->name);
+
+		// Do the delete
+		$this->db->delete('job', array('id' => 1));
+
+		// Check the record
+		$job1 = $this->db->where('id', 1)
+							->get('job');
+
+		$this->assertEmpty($job1->result_array());
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_delete_several_tables()
+	{
+		// Check initial record
+		$user4 = $this->db->where('id', 4)
+							->get('user')
+							->row();
+
+		$job4 = $this->db->where('id', 4)
+							->get('job')
+							->row();
+
+		$this->assertEquals('Musician', $job4->name);
+		$this->assertEquals('Chris Martin', $user4->name);
+
+		// Do the delete
+		$this->db->delete(array('job', 'user'), array('id' => 4));
+
+		// Check the record
+		$job4 = $this->db->where('id', 4)->get('job');
+		$user4 = $this->db->where('id', 4)->get('user');
+
+		$this->assertEmpty($job4->result_array());
+		$this->assertEmpty($user4->result_array());
+	}
+
+}
\ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/distinct_test.php b/tests/codeigniter/database/query_builder/distinct_test.php
new file mode 100644
index 0000000..925eadb
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/distinct_test.php
@@ -0,0 +1,34 @@
+<?php
+
+class Distinct_test extends CI_TestCase {
+
+	/**
+	 * @var object Database/Query Builder holder
+	 */
+	protected $db;
+
+	public function set_up()
+	{
+		$this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+		Mock_Database_Schema_Skeleton::create_tables();
+		Mock_Database_Schema_Skeleton::create_data();
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_distinct()
+	{
+		$users = $this->db->select('country')
+							  ->distinct()
+		                      ->get('user')
+		                      ->result_array();
+		
+		// Check the result
+		$this->assertEquals(3, count($users));
+	}
+
+}
\ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/empty_test.php b/tests/codeigniter/database/query_builder/empty_test.php
new file mode 100644
index 0000000..d1f5628
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/empty_test.php
@@ -0,0 +1,39 @@
+<?php
+
+class Empty_test extends CI_TestCase {
+
+	/**
+	 * @var object Database/Query Builder holder
+	 */
+	protected $db;
+
+	public function set_up()
+	{
+		$this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+		Mock_Database_Schema_Skeleton::create_tables();
+		Mock_Database_Schema_Skeleton::create_data();
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_empty_table()
+	{
+		// Check initial record
+		$jobs = $this->db->get('job')->result_array();
+
+		$this->assertEquals(4, count($jobs));
+
+		// Do the empty
+		$this->db->empty_table('job');
+
+		// Check the record
+		$jobs = $this->db->get('job');
+
+		$this->assertEmpty($jobs->result_array());
+	}
+
+}
\ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/from_test.php b/tests/codeigniter/database/query_builder/from_test.php
new file mode 100644
index 0000000..95ae4df
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/from_test.php
@@ -0,0 +1,51 @@
+<?php
+
+class From_test extends CI_TestCase {
+
+	/**
+	 * @var object Database/Query Builder holder
+	 */
+	protected $db;
+
+	public function set_up()
+	{
+		$this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+		Mock_Database_Schema_Skeleton::create_tables();
+		Mock_Database_Schema_Skeleton::create_data();
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_from_simple()
+	{
+		$jobs = $this->db->from('job')
+		                      ->get()
+		                      ->result_array();
+		
+		// Check items
+		$this->assertEquals(4, count($jobs));
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_from_with_where()
+	{
+		$job1 = $this->db->from('job')
+							->where('id', 1)
+		                    ->get()
+		                    ->row();
+		
+		// Check the result
+		$this->assertEquals('1', $job1->id);
+		$this->assertEquals('Developer', $job1->name);
+		$this->assertEquals('Awesome job, but sometimes makes you bored', $job1->description);
+	}
+	
+}
\ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/group_test.php b/tests/codeigniter/database/query_builder/group_test.php
new file mode 100644
index 0000000..7d8abc3
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/group_test.php
@@ -0,0 +1,53 @@
+<?php
+
+class Group_test extends CI_TestCase {
+
+	/**
+	 * @var object Database/Query Builder holder
+	 */
+	protected $db;
+
+	public function set_up()
+	{
+		$this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+		Mock_Database_Schema_Skeleton::create_tables();
+		Mock_Database_Schema_Skeleton::create_data();
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_group_by()
+	{
+		$jobs = $this->db->select('name')
+							  ->from('job')
+							  ->group_by('name')
+		                      ->get()
+		                      ->result_array();
+		
+		// Check the result
+		$this->assertEquals(4, count($jobs));
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_having_by()
+	{
+		$jobs = $this->db->select('name')
+							  ->from('job')
+							  ->group_by('name')
+							  ->having('SUM(id) > 2')
+		                      ->get()
+		                      ->result_array();
+		
+		// Check the result
+		$this->assertEquals(2, count($jobs));
+	}
+	
+}
\ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/insert_test.php b/tests/codeigniter/database/query_builder/insert_test.php
index 53ce23c..8ba60e2 100644
--- a/tests/codeigniter/database/query_builder/insert_test.php
+++ b/tests/codeigniter/database/query_builder/insert_test.php
@@ -30,11 +30,10 @@
 		// Do normal insert
 		$this->assertTrue($this->db->insert('job', $job_data));
 
-		$jobs = $this->db->get('job')->result_array();
-		$job1 = $jobs[0];
+		$job1 = $this->db->get('job')->row();
 
 		// Check the result
-		$this->assertEquals('Grocery Sales', $job1['name']);
+		$this->assertEquals('Grocery Sales', $job1->name);
 
 	}
 
diff --git a/tests/codeigniter/database/query_builder/join_test.php b/tests/codeigniter/database/query_builder/join_test.php
new file mode 100644
index 0000000..e05329d
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/join_test.php
@@ -0,0 +1,38 @@
+<?php
+
+class Join_test extends CI_TestCase {
+
+	/**
+	 * @var object Database/Query Builder holder
+	 */
+	protected $db;
+
+	public function set_up()
+	{
+		$this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+		Mock_Database_Schema_Skeleton::create_tables();
+		Mock_Database_Schema_Skeleton::create_data();
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_join_simple()
+	{
+		$job_user = $this->db->select('job.id as job_id, job.name as job_name, user.id as user_id, user.name as user_name')
+							->from('job')
+							->join('user', 'user.id = job.id')
+							->get()
+							->result_array();
+
+		// Check the result
+		$this->assertEquals('1', $job_user[0]['job_id']);
+		$this->assertEquals('1', $job_user[0]['user_id']);
+		$this->assertEquals('Derek Jones', $job_user[0]['user_name']);
+		$this->assertEquals('Developer', $job_user[0]['job_name']);
+	}
+	
+}
\ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/like_test.php b/tests/codeigniter/database/query_builder/like_test.php
new file mode 100644
index 0000000..df98c71
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/like_test.php
@@ -0,0 +1,90 @@
+<?php
+
+class Like_test extends CI_TestCase {
+
+	/**
+	 * @var object Database/Query Builder holder
+	 */
+	protected $db;
+
+	public function set_up()
+	{
+		$this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+		Mock_Database_Schema_Skeleton::create_tables();
+		Mock_Database_Schema_Skeleton::create_data();
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_like()
+	{
+		$job1 = $this->db->like('name', 'veloper')
+							->get('job')
+							->row();
+
+		// Check the result
+		$this->assertEquals('1', $job1->id);
+		$this->assertEquals('Developer', $job1->name);
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_or_like()
+	{
+		$jobs = $this->db->like('name', 'ian')
+							->or_like('name', 'veloper')
+							->get('job')
+							->result_array();
+
+		// Check the result
+		$this->assertEquals(3, count($jobs));
+		$this->assertEquals('Developer', $jobs[0]['name']);
+		$this->assertEquals('Politician', $jobs[1]['name']);
+		$this->assertEquals('Musician', $jobs[2]['name']);
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_not_like()
+	{
+		$jobs = $this->db->not_like('name', 'veloper')
+							->get('job')
+							->result_array();
+
+		// Check the result
+		$this->assertEquals(3, count($jobs));
+		$this->assertEquals('Politician', $jobs[0]['name']);
+		$this->assertEquals('Accountant', $jobs[1]['name']);
+		$this->assertEquals('Musician', $jobs[2]['name']);
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_or_not_like()
+	{
+		$jobs = $this->db->like('name', 'an')
+							->or_not_like('name', 'veloper')
+							->get('job')
+							->result_array();
+
+		// Check the result
+		$this->assertEquals(3, count($jobs));
+		$this->assertEquals('Politician', $jobs[0]['name']);
+		$this->assertEquals('Accountant', $jobs[1]['name']);
+		$this->assertEquals('Musician', $jobs[2]['name']);
+	}
+	
+}
\ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/limit_test.php b/tests/codeigniter/database/query_builder/limit_test.php
new file mode 100644
index 0000000..704f3b6
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/limit_test.php
@@ -0,0 +1,49 @@
+<?php
+
+class Limit_test extends CI_TestCase {
+
+	/**
+	 * @var object Database/Query Builder holder
+	 */
+	protected $db;
+
+	public function set_up()
+	{
+		$this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+		Mock_Database_Schema_Skeleton::create_tables();
+		Mock_Database_Schema_Skeleton::create_data();
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_limit()
+	{
+		$jobs = $this->db->limit(2)
+		                      ->get('job')
+		                      ->result_array();
+		
+		// Check the result
+		$this->assertEquals(2, count($jobs));
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_limit_and_offset()
+	{
+		$jobs = $this->db->limit(2, 2)
+		                      ->get('job')
+		                      ->result_array();
+		
+		// Check the result
+		$this->assertEquals(2, count($jobs));
+		$this->assertEquals('Accountant', $jobs[0]['name']);
+		$this->assertEquals('Musician', $jobs[1]['name']);
+	}
+}
\ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/order_test.php b/tests/codeigniter/database/query_builder/order_test.php
new file mode 100644
index 0000000..01aa1c2
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/order_test.php
@@ -0,0 +1,55 @@
+<?php
+
+class Order_test extends CI_TestCase {
+
+	/**
+	 * @var object Database/Query Builder holder
+	 */
+	protected $db;
+
+	public function set_up()
+	{
+		$this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+		Mock_Database_Schema_Skeleton::create_tables();
+		Mock_Database_Schema_Skeleton::create_data();
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_order_ascending()
+	{
+		$jobs = $this->db->order_by('name', 'asc')
+		                      ->get('job')
+		                      ->result_array();
+		
+		// Check the result
+		$this->assertEquals(4, count($jobs));
+		$this->assertEquals('Accountant', $jobs[0]['name']);
+		$this->assertEquals('Developer', $jobs[1]['name']);
+		$this->assertEquals('Musician', $jobs[2]['name']);
+		$this->assertEquals('Politician', $jobs[3]['name']);
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_order_descending()
+	{
+		$jobs = $this->db->order_by('name', 'desc')
+		                      ->get('job')
+		                      ->result_array();
+		
+		// Check the result
+		$this->assertEquals(4, count($jobs));
+		$this->assertEquals('Politician', $jobs[0]['name']);
+		$this->assertEquals('Musician', $jobs[1]['name']);
+		$this->assertEquals('Developer', $jobs[2]['name']);
+		$this->assertEquals('Accountant', $jobs[3]['name']);
+	}
+}
\ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/select_test.php b/tests/codeigniter/database/query_builder/select_test.php
index dbf432a..0d299ed 100644
--- a/tests/codeigniter/database/query_builder/select_test.php
+++ b/tests/codeigniter/database/query_builder/select_test.php
@@ -41,10 +41,10 @@
 	{
 		$job_min = $this->db->select_min('id')
 		                    ->get('job')
-		                    ->result_array();
+		                    ->row();
 		
 		// Minimum id was 1
-		$this->assertEquals('1', $job_min[0]['id']);
+		$this->assertEquals('1', $job_min->id);
 	}
 
 	// ------------------------------------------------------------------------
@@ -56,10 +56,10 @@
 	{
 		$job_max = $this->db->select_max('id')
 		                    ->get('job')
-		                    ->result_array();
+		                    ->row();
 		
 		// Maximum id was 4
-		$this->assertEquals('4', $job_max[0]['id']);
+		$this->assertEquals('4', $job_max->id);
 	}
 
 	// ------------------------------------------------------------------------
@@ -71,10 +71,10 @@
 	{
 		$job_avg = $this->db->select_avg('id')
 		                    ->get('job')
-		                    ->result_array();
+		                    ->row();
 		
 		// Average should be 2.5
-		$this->assertEquals('2.5', $job_avg[0]['id']);
+		$this->assertEquals('2.5', $job_avg->id);
 	}
 
 	// ------------------------------------------------------------------------
@@ -86,10 +86,10 @@
 	{
 		$job_sum = $this->db->select_sum('id')
 		                    ->get('job')
-		                    ->result_array();
+		                    ->row();
 		
 		// Sum of ids should be 10
-		$this->assertEquals('10', $job_sum[0]['id']);
+		$this->assertEquals('10', $job_sum->id);
 	}
 	
 }
\ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/truncate_test.php b/tests/codeigniter/database/query_builder/truncate_test.php
new file mode 100644
index 0000000..2a9c8a9
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/truncate_test.php
@@ -0,0 +1,61 @@
+<?php
+
+class Truncate_test extends CI_TestCase {
+
+	/**
+	 * @var object Database/Query Builder holder
+	 */
+	protected $db;
+
+	public function set_up()
+	{
+		$this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+		Mock_Database_Schema_Skeleton::create_tables();
+		Mock_Database_Schema_Skeleton::create_data();
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_truncate()
+	{
+		// Check initial record
+		$jobs = $this->db->get('job')->result_array();
+
+		$this->assertEquals(4, count($jobs));
+
+		// Do the empty
+		$this->db->truncate('job');
+
+		// Check the record
+		$jobs = $this->db->get('job');
+
+		$this->assertEmpty($jobs->result_array());
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_truncate_with_from()
+	{
+		// Check initial record
+		$users = $this->db->get('user')->result_array();
+
+		$this->assertEquals(4, count($users));
+
+		// Do the empty
+		$this->db->from('user')
+					->truncate();
+
+		// Check the record
+		$users = $this->db->get('user');
+
+		$this->assertEmpty($users->result_array());
+	}
+
+}
\ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/update_test.php b/tests/codeigniter/database/query_builder/update_test.php
new file mode 100644
index 0000000..f5bbffd
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/update_test.php
@@ -0,0 +1,71 @@
+<?php
+
+class Update_test extends CI_TestCase {
+
+	/**
+	 * @var object Database/Query Builder holder
+	 */
+	protected $db;
+
+	public function set_up()
+	{
+		$this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+		Mock_Database_Schema_Skeleton::create_tables();
+		Mock_Database_Schema_Skeleton::create_data();
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_update()
+	{
+		// Check initial record
+		$job1 = $this->db->where('id', 1)
+							->get('job')
+							->row();
+
+		$this->assertEquals('Developer', $job1->name);
+
+		// Do the update
+		$job_data = array('name' => 'Programmer');
+
+		$this->db->where('id', 1)
+						->update('job', $job_data);
+
+		// Check updated record
+		$job1 = $this->db->where('id', 1)
+							->get('job')
+							->row();
+
+		$this->assertEquals('Programmer', $job1->name);
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_update_with_set()
+	{
+		// Check initial record
+		$job1 = $this->db->where('id', 4)
+							->get('job')
+							->row();
+
+		$this->assertEquals('Musician', $job1->name);
+
+		// Do the update
+		$this->db->set('name', 'Vocalist');
+		$this->db->update('job', NULL, 'id = 4');
+
+		// Check updated record
+		$job1 = $this->db->where('id', 4)
+							->get('job')
+							->row();
+
+		$this->assertEquals('Vocalist', $job1->name);
+	}
+}
\ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/where_test.php b/tests/codeigniter/database/query_builder/where_test.php
new file mode 100644
index 0000000..607eaa0
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/where_test.php
@@ -0,0 +1,144 @@
+<?php
+
+class Where_test extends CI_TestCase {
+
+	/**
+	 * @var object Database/Query Builder holder
+	 */
+	protected $db;
+
+	public function set_up()
+	{
+		$this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+		Mock_Database_Schema_Skeleton::create_tables();
+		Mock_Database_Schema_Skeleton::create_data();
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_where_simple_key_value()
+	{
+		$job1 = $this->db->where('id', 1)
+							->get('job')
+							->row();
+
+		// Check the result
+		$this->assertEquals('1', $job1->id);
+		$this->assertEquals('Developer', $job1->name);
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_where_custom_key_value()
+	{
+		$jobs = $this->db->where('id !=', 1)
+							->get('job')
+							->result_array();
+
+		// Check the result
+		$this->assertEquals(3, count($jobs));
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_where_associative_array()
+	{
+		$where = array('id >' => 2, 'name !=' => 'Accountant');
+		$jobs = $this->db->where($where)
+							->get('job')
+							->result_array();
+
+		// Check the result
+		$this->assertEquals(1, count($jobs));
+
+		// Should be Musician
+		$job = current($jobs);
+
+		$this->assertEquals('Musician', $job['name']);
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_where_custom_string()
+	{
+		$where = "id > 2 AND name != 'Accountant'";
+		$jobs = $this->db->where($where)
+							->get('job')
+							->result_array();
+
+		// Check the result
+		$this->assertEquals(1, count($jobs));
+
+		// Should be Musician
+		$job = current($jobs);
+
+		$this->assertEquals('Musician', $job['name']);
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_where_or()
+	{
+		$jobs = $this->db->where('name !=', 'Accountant')
+							->or_where('id >', 3)
+							->get('job')
+							->result_array();
+
+		// Check the result
+		$this->assertEquals(3, count($jobs));
+		$this->assertEquals('Developer', $jobs[0]['name']);
+		$this->assertEquals('Politician', $jobs[1]['name']);
+		$this->assertEquals('Musician', $jobs[2]['name']);
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_where_in()
+	{
+		$jobs = $this->db->where_in('name', array('Politician', 'Accountant'))
+							->get('job')
+							->result_array();
+
+		// Check the result
+		$this->assertEquals(2, count($jobs));
+		$this->assertEquals('Politician', $jobs[0]['name']);
+		$this->assertEquals('Accountant', $jobs[1]['name']);
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_where_not_in()
+	{
+		$jobs = $this->db->where_not_in('name', array('Politician', 'Accountant'))
+							->get('job')
+							->result_array();
+
+		// Check the result
+		$this->assertEquals(2, count($jobs));
+		$this->assertEquals('Developer', $jobs[0]['name']);
+		$this->assertEquals('Musician', $jobs[1]['name']);
+	}
+	
+}
\ No newline at end of file
diff --git a/tests/mocks/autoloader.php b/tests/mocks/autoloader.php
index f1bdb5d..92c9bea 100644
--- a/tests/mocks/autoloader.php
+++ b/tests/mocks/autoloader.php
@@ -6,7 +6,6 @@
 //
 // Prototype :
 //
-// include_once('Mock_Core_Loader') 					// Will load ./mocks/core/loader.php
 // $mock_table = new Mock_Libraries_Table(); 			// Will load ./mocks/libraries/table.php
 // $mock_database_driver = new Mock_Database_Driver();	// Will load ./mocks/database/driver.php 
 // and so on...
diff --git a/tests/mocks/core/benchmark.php b/tests/mocks/core/benchmark.php
new file mode 100644
index 0000000..d92be21
--- /dev/null
+++ b/tests/mocks/core/benchmark.php
@@ -0,0 +1,3 @@
+<?php
+
+class Mock_Core_Benchmark extends CI_Benchmark {}
\ No newline at end of file
diff --git a/tests/mocks/core/input.php b/tests/mocks/core/input.php
new file mode 100644
index 0000000..8a337d2
--- /dev/null
+++ b/tests/mocks/core/input.php
@@ -0,0 +1,31 @@
+<?php
+
+class Mock_Core_Input extends CI_Input {
+	
+	/**
+	 * Since we use GLOBAL to fetch Security and Utf8 classes, 
+	 * we need to use inversion of control to mock up 
+	 * the same process within CI_Input class constructor.
+	 *
+	 * @covers CI_Input::__construct()
+	 */
+	public function __construct($security, $utf8)
+	{
+		$this->_allow_get_array	= (config_item('allow_get_array') === TRUE);
+		$this->_enable_xss	= (config_item('global_xss_filtering') === TRUE);
+		$this->_enable_csrf	= (config_item('csrf_protection') === TRUE);
+
+		// Assign Security and Utf8 classes
+		$this->security = $security;
+		$this->uni = $utf8;
+
+		// Sanitize global arrays
+		$this->_sanitize_globals();
+	}
+
+	public function fetch_from_array($array, $index = '', $xss_clean = FALSE)
+	{
+		return parent::_fetch_from_array($array, $index, $xss_clean);
+	}
+
+}
\ No newline at end of file
diff --git a/tests/mocks/core/security.php b/tests/mocks/core/security.php
new file mode 100644
index 0000000..d7ea0e6
--- /dev/null
+++ b/tests/mocks/core/security.php
@@ -0,0 +1,30 @@
+<?php
+
+class Mock_Core_Security extends CI_Security {
+	
+	public function csrf_set_cookie()
+	{
+		// We cannot set cookie in CLI mode, so for csrf test, who rely on $_COOKIE,
+		// we superseded set_cookie with directly set the cookie variable,
+		// @see : ./tests/codeigniter/core/Security_test.php, line 8
+		return $this;
+	}
+
+	// Overide inaccesible protected properties
+	public function __get($property)
+	{
+		return isset($this->{'_'.$property}) ? $this->{'_'.$property} : NULL;
+	}
+
+	// Overide inaccesible protected method
+	public function __call($method, $params)
+	{
+		if (is_callable(array($this, '_'.$method)))
+		{
+			return call_user_func_array(array($this, '_'.$method), $params);
+		}
+
+		throw new BadMethodCallException('Method '.$method.' was not found');
+	}
+
+}
\ No newline at end of file
diff --git a/tests/mocks/core/utf8.php b/tests/mocks/core/utf8.php
new file mode 100644
index 0000000..b77d717
--- /dev/null
+++ b/tests/mocks/core/utf8.php
@@ -0,0 +1,27 @@
+<?php
+
+class Mock_Core_Utf8 extends CI_Utf8 {
+	
+	/**
+	 * We need to define several constants as 
+	 * the same process within CI_Utf8 class constructor.
+	 *
+	 * @covers CI_Utf8::__construct()
+	 */
+	public function __construct()
+	{
+		defined('UTF8_ENABLED') or define('UTF8_ENABLED', TRUE);
+
+		if (extension_loaded('mbstring'))
+		{
+			defined('MB_ENABLED') or define('MB_ENABLED', TRUE);
+			mb_internal_encoding('UTF-8');
+		}
+		else
+		{
+			defined('MB_ENABLED') or define('MB_ENABLED', FALSE);
+		}
+		
+	}
+
+}
\ No newline at end of file
diff --git a/tests/mocks/database/ci_test.sqlite b/tests/mocks/database/ci_test.sqlite
index 86d868a..23a3de2 100755
--- a/tests/mocks/database/ci_test.sqlite
+++ b/tests/mocks/database/ci_test.sqlite
Binary files differ
diff --git a/tests/mocks/database/schema/skeleton.php b/tests/mocks/database/schema/skeleton.php
index a3d5bac..671336c 100644
--- a/tests/mocks/database/schema/skeleton.php
+++ b/tests/mocks/database/schema/skeleton.php
@@ -50,6 +50,28 @@
 	 */
 	public static function create_tables()
 	{
+		// User Table
+		static::$forge->add_field(array(
+			'id' => array(
+				'type' => 'INTEGER',
+				'constraint' => 3,
+			),
+			'name' => array(
+				'type' => 'VARCHAR',
+				'constraint' => 40,
+			),
+			'email' => array(
+				'type' => 'VARCHAR',
+				'constraint' => 100,
+			),
+			'country' => array(
+				'type' => 'VARCHAR',
+				'constraint' => 40,
+			),
+		));
+		static::$forge->add_key('id', TRUE);
+		static::$forge->create_table('user', (strpos(static::$driver, 'pgsql') === FALSE));
+
 		// Job Table
 		static::$forge->add_field(array(
 			'id' => array(
@@ -77,6 +99,12 @@
 	{
 		// Job Data
 		$data = array(
+			'user' => array(
+				array('id' => 1, 'name' => 'Derek Jones', 'email' => 'derek@world.com', 'country' => 'US'),
+				array('id' => 2, 'name' => 'Ahmadinejad', 'email' => 'ahmadinejad@world.com', 'country' => 'Iran'),
+				array('id' => 3, 'name' => 'Richard A Causey', 'email' => 'richard@world.com', 'country' => 'US'),
+				array('id' => 4, 'name' => 'Chris Martin', 'email' => 'chris@world.com', 'country' => 'UK'),
+			),
 			'job' => array(
 				array('id' => 1, 'name' => 'Developer', 'description' => 'Awesome job, but sometimes makes you bored'), 
 				array('id' => 2, 'name' => 'Politician', 'description' => 'This is not really a job'),
diff --git a/tests/mocks/libraries/table.php b/tests/mocks/libraries/table.php
index 1a6ff8d..97fbb30 100644
--- a/tests/mocks/libraries/table.php
+++ b/tests/mocks/libraries/table.php
@@ -2,7 +2,7 @@
 
 class Mock_Libraries_Table extends CI_Table {
 	
-	// Overide inaccesible private or protected method
+	// Overide inaccesible protected method
 	public function __call($method, $params)
 	{
 		if (is_callable(array($this, '_'.$method)))
diff --git a/tests/travis/mysql.phpunit.xml b/tests/travis/mysql.phpunit.xml
index e9556f7..1792ae3 100644
--- a/tests/travis/mysql.phpunit.xml
+++ b/tests/travis/mysql.phpunit.xml
@@ -14,19 +14,13 @@
     </php>
 	<testsuites>
 		<testsuite name="CodeIgniter Core Test Suite">
-			<file>../codeigniter/Setup_test.php</file>
-			<directory suffix="test.php">../codeigniter/core</directory>
-			<directory suffix="test.php">../codeigniter/helpers</directory>
-			<directory suffix="test.php">../codeigniter/libraries</directory>
-			<directory suffix="test.php">../codeigniter/database</directory>
+			<directory suffix="test.php">../codeigniter</directory>
 		</testsuite>
 	</testsuites>
 	<filters>
 		<blacklist>
 			<directory suffix=".php">PEAR_INSTALL_DIR</directory>
 			<directory suffix=".php">PHP_LIBDIR</directory>
-			<directory suffix=".php">PROJECT_BASE.'tests'</directory>
-			<directory suffix=".php">'../../system/core/CodeIgniter.php'</directory>
 		</blacklist>
 	</filters>
 </phpunit>
\ No newline at end of file
diff --git a/tests/travis/pdo/mysql.phpunit.xml b/tests/travis/pdo/mysql.phpunit.xml
index 69eece2..602030d 100644
--- a/tests/travis/pdo/mysql.phpunit.xml
+++ b/tests/travis/pdo/mysql.phpunit.xml
@@ -14,19 +14,13 @@
     </php>
 	<testsuites>
 		<testsuite name="CodeIgniter Core Test Suite">
-			<file>../../codeigniter/Setup_test.php</file>
-			<directory suffix="test.php">../../codeigniter/core</directory>
-			<directory suffix="test.php">../../codeigniter/helpers</directory>
-			<directory suffix="test.php">../../codeigniter/libraries</directory>
-			<directory suffix="test.php">../../codeigniter/database</directory>
+			<directory suffix="test.php">../../codeigniter</directory>
 		</testsuite>
 	</testsuites>
 	<filters>
 		<blacklist>
 			<directory suffix=".php">PEAR_INSTALL_DIR</directory>
 			<directory suffix=".php">PHP_LIBDIR</directory>
-			<directory suffix=".php">PROJECT_BASE.'tests'</directory>
-			<directory suffix=".php">'../../../system/core/CodeIgniter.php'</directory>
 		</blacklist>
 	</filters>
 </phpunit>
\ No newline at end of file
diff --git a/tests/travis/pdo/pgsql.phpunit.xml b/tests/travis/pdo/pgsql.phpunit.xml
index e68c3e0..77e1493 100644
--- a/tests/travis/pdo/pgsql.phpunit.xml
+++ b/tests/travis/pdo/pgsql.phpunit.xml
@@ -14,19 +14,13 @@
     </php>
 	<testsuites>
 		<testsuite name="CodeIgniter Core Test Suite">
-			<file>../../codeigniter/Setup_test.php</file>
-			<directory suffix="test.php">../../codeigniter/core</directory>
-			<directory suffix="test.php">../../codeigniter/helpers</directory>
-			<directory suffix="test.php">../../codeigniter/libraries</directory>
-			<directory suffix="test.php">../../codeigniter/database</directory>
+			<directory suffix="test.php">../../codeigniter</directory>
 		</testsuite>
 	</testsuites>
 	<filters>
 		<blacklist>
 			<directory suffix=".php">PEAR_INSTALL_DIR</directory>
 			<directory suffix=".php">PHP_LIBDIR</directory>
-			<directory suffix=".php">PROJECT_BASE.'tests'</directory>
-			<directory suffix=".php">'../../../system/core/CodeIgniter.php'</directory>
 		</blacklist>
 	</filters>
 </phpunit>
\ No newline at end of file
diff --git a/tests/travis/pdo/sqlite.phpunit.xml b/tests/travis/pdo/sqlite.phpunit.xml
index 1871f62..cdccef0 100644
--- a/tests/travis/pdo/sqlite.phpunit.xml
+++ b/tests/travis/pdo/sqlite.phpunit.xml
@@ -14,19 +14,13 @@
     </php>
 	<testsuites>
 		<testsuite name="CodeIgniter Core Test Suite">
-			<file>../../codeigniter/Setup_test.php</file>
-			<directory suffix="test.php">../../codeigniter/core</directory>
-			<directory suffix="test.php">../../codeigniter/helpers</directory>
-			<directory suffix="test.php">../../codeigniter/libraries</directory>
-			<directory suffix="test.php">../../codeigniter/database</directory>
+			<directory suffix="test.php">../../codeigniter</directory>
 		</testsuite>
 	</testsuites>
 	<filters>
 		<blacklist>
 			<directory suffix=".php">PEAR_INSTALL_DIR</directory>
 			<directory suffix=".php">PHP_LIBDIR</directory>
-			<directory suffix=".php">PROJECT_BASE.'tests'</directory>
-			<directory suffix=".php">'../../../system/core/CodeIgniter.php'</directory>
 		</blacklist>
 	</filters>
 </phpunit>
\ No newline at end of file
diff --git a/tests/travis/pgsql.phpunit.xml b/tests/travis/pgsql.phpunit.xml
index ad8aede..dfc1bff 100644
--- a/tests/travis/pgsql.phpunit.xml
+++ b/tests/travis/pgsql.phpunit.xml
@@ -14,19 +14,13 @@
     </php>
 	<testsuites>
 		<testsuite name="CodeIgniter Core Test Suite">
-			<file>../codeigniter/Setup_test.php</file>
-			<directory suffix="test.php">../codeigniter/core</directory>
-			<directory suffix="test.php">../codeigniter/helpers</directory>
-			<directory suffix="test.php">../codeigniter/libraries</directory>
-			<directory suffix="test.php">../codeigniter/database</directory>
+			<directory suffix="test.php">../codeigniter</directory>
 		</testsuite>
 	</testsuites>
 	<filters>
 		<blacklist>
 			<directory suffix=".php">PEAR_INSTALL_DIR</directory>
 			<directory suffix=".php">PHP_LIBDIR</directory>
-			<directory suffix=".php">PROJECT_BASE.'tests'</directory>
-			<directory suffix=".php">'../../system/core/CodeIgniter.php'</directory>
 		</blacklist>
 	</filters>
 </phpunit>
\ No newline at end of file
diff --git a/tests/travis/sqlite.phpunit.xml b/tests/travis/sqlite.phpunit.xml
index 628370e..3223da5 100644
--- a/tests/travis/sqlite.phpunit.xml
+++ b/tests/travis/sqlite.phpunit.xml
@@ -14,19 +14,13 @@
     </php>
 	<testsuites>
 		<testsuite name="CodeIgniter Core Test Suite">
-			<file>../codeigniter/Setup_test.php</file>
-			<directory suffix="test.php">../codeigniter/core</directory>
-			<directory suffix="test.php">../codeigniter/helpers</directory>
-			<directory suffix="test.php">../codeigniter/libraries</directory>
-			<directory suffix="test.php">../codeigniter/database</directory>
+			<directory suffix="test.php">../codeigniter</directory>
 		</testsuite>
 	</testsuites>
 	<filters>
 		<blacklist>
 			<directory suffix=".php">PEAR_INSTALL_DIR</directory>
 			<directory suffix=".php">PHP_LIBDIR</directory>
-			<directory suffix=".php">PROJECT_BASE.'tests'</directory>
-			<directory suffix=".php">'../../system/core/CodeIgniter.php'</directory>
 		</blacklist>
 	</filters>
 </phpunit>
\ No newline at end of file
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index bbbe6f7..e0d745f 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -9,8 +9,7 @@
 
 -  License
 
-   -  CodeIgniter has been relicensed with the Open Software License (3.0),
-      eliminating its old proprietary licensing.
+   -  CodeIgniter has been relicensed with the Open Software License (3.0), eliminating its old proprietary licensing.
 
       -  All system files are licensed with OSL 3.0.
       -  Config, error, and sample files shipped in the application folder are
@@ -22,7 +21,7 @@
    -  PHP 5.1.6 is no longer supported. CodeIgniter now requires PHP 5.2.4.
    -  Added an optional backtrace to php-error template.
    -  Added Android to the list of user agents.
-   -  Added Windows 7 to the list of user platforms.
+   -  Added Windows 7, Android, Blackberry and iOS to the list of user platforms.
    -  Ability to log certain error types, not all under a threshold.
    -  Added support for pem, p10, p12, p7a, p7c, p7m, p7r, p7s, crt, crl, der, kdb, rsa, cer, sst, csr Certs to mimes.php.
    -  Added support for pgp and gpg to mimes.php.
@@ -38,12 +37,13 @@
       Only entries in ``$autoload['libraries']`` are auto-loaded now.
    -  Added some more doctypes.
    -  Updated all classes to be written in PHP 5 style, with visibility declarations and no ``var`` usage for properties.
+   -  Moved error templates to "application/views/errors"
 
 -  Helpers
 
    -  url_title() will now trim extra dashes from beginning and end.
    -  Added XHTML Basic 1.1 doctype to :doc:`HTML Helper <helpers/html_helper>`.
-   -  Changed humanize to include a second param for the separator.
+   -  Changed humanize() to include a second param for the separator.
    -  Refactored ``plural()`` and ``singular()`` to avoid double pluralization and support more words.
    -  Added an optional third parameter to ``force_download()`` that enables/disables sending the actual file MIME type in the Content-Type header (disabled by default).
    -  Added an optional third parameter to ``timespan()`` that constrains the number of time units displayed.
@@ -52,24 +52,21 @@
    -  set_realpath() can now also handle file paths as opposed to just directories.
    -  do_hash() now uses PHP's native hash() function, supporting more algorithms.
    -  Added an optional paramater to ``delete_files()`` to enable it to skip deleting files such as .htaccess and index.html.
+   -  Removed deprecated helper function ``js_insert_smiley()`` from smiley helper.
 
 -  Database
 
-   -  Renamed the Active Record class to Query Builder to remove confusion with 
-      the Active Record design pattern
-   -  Added new :doc:`Query Builder <database/query_builder>` methods that return
+   -  Renamed the Active Record class to Query Builder to remove confusion with the Active Record design pattern.
    -  Added the ability to insert objects with insert_batch() in :doc:`Query Builder <database/query_builder>`.
-   -  Added new :doc:`Query Builder <database/query_builder>` methods that return
-      the SQL string of queries without executing them: get_compiled_select(),
-      get_compiled_insert(), get_compiled_update(), get_compiled_delete().
-   -  Adding $escape parameter to the order_by function, this enables ordering by custom fields.
+   -  Added new :doc:`Query Builder <database/query_builder>` methods that return the SQL string of queries without executing them: get_compiled_select(), get_compiled_insert(), get_compiled_update(), get_compiled_delete().
+   -  Adding $escape parameter to the order_by() method, this enables ordering by custom fields.
    -  Improved support for the MySQLi driver, including:
 	 -  OOP style of the PHP extension is now used, instead of the procedural aliases.
 	 -  Server version checking is now done via ``mysqli::$server_info`` instead of running an SQL query.
 	 -  Added persistent connections support for PHP >= 5.3.
    -  Added 'dsn' configuration setting for drivers that support DSN strings (PDO, PostgreSQL, Oracle, ODBC, CUBRID).
    -  Improved PDO database support.
-   -  Added Interbase/Firebird database support via the "interbase" driver
+   -  Added Interbase/Firebird database support via the "interbase" driver.
    -  Added an optional database name parameter to db_select().
    -  Replaced the _error_message() and _error_number() methods with error(), that returns an array containing the last database error code and message.
    -  Improved version() implementation so that drivers that have a native function to get the version number don't have to be defined in the core DB_driver class.
@@ -77,6 +74,7 @@
 	 -  pg_version() is now used to get the database version number, when possible.
 	 -  Added db_set_charset() support.
 	 -  Added _optimize_table() support for the :doc:`Database Utility Class <database/utilities>` (rebuilds table indexes).
+	 -  Added boolean data type support in escape().
    -  Added a constructor to the DB_result class and moved all driver-specific properties and logic out of the base DB_driver class to allow better abstraction.
    -  Removed limit() and order_by() support for UPDATE and DELETE queries in PostgreSQL driver. Postgres does not support those features.
    -  Removed protect_identifiers() and renamed internal method _protect_identifiers() to it instead - it was just an alias.
@@ -100,6 +98,7 @@
    -  Added PDO support for create_database(), drop_database and drop_table() in :doc:`Database Forge <database/forge>`.
    -  Added MSSQL, SQLSRV support for optimize_table() in :doc:`Database Utility <database/utilities>`.
    -  Improved CUBRID support for list_databases() in :doc:`Database Utility <database/utilities>` (until now only the currently used database was returned).
+   -  Added unbuffered_row() method for getting a row without prefetching whole result (consume less memory).
 
 -  Libraries
 
@@ -107,17 +106,15 @@
    -  CI_Loader::_ci_autoloader() is now a protected method.
    -  Added custom filename to Email::attach() as $this->email->attach($filename, $disposition, $newname).
    -  Added possibility to send attachment as buffer string in Email::attach() as $this->email->attach($buffer, $disposition, $newname, $mime).
-   -  Cart library changes include:
+   -  :doc:`Cart library <libraries/cart>` 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
+	 -  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.
    -  :doc:`Image Manipulation library <libraries/image_lib>` changes include:
 	 -  The initialize() method now only sets existing class properties.
 	 -  Added support for 3-length hex color values for wm_font_color and wm_shadow_color properties, as well as validation for them.
-	 -  Class properties wm_font_color, wm_shadow_color and wm_use_drop_shadow are now protected, to avoid breaking the text_watermark() method
-	    if they are set manually after initialization.
+	 -  Class properties wm_font_color, wm_shadow_color and wm_use_drop_shadow are now protected, to avoid breaking the text_watermark() method if they are set manually after initialization.
 	 -  If property maintain_ratio is set to TRUE, image_reproportion() now doesn't need both width and height to be specified.
-   -  Minor speed optimizations and method & property visibility declarations in the Calendar Library.
    -  Removed SHA1 function in the :doc:`Encryption Library <libraries/encryption>`.
    -  Added $config['csrf_regeneration'] to the CSRF protection in the :doc:`Security library <libraries/security>`, which makes token regeneration optional.
    -  :doc:`Form Validation library <libraries/form_validation>` changes include:
@@ -150,26 +147,26 @@
 Bug fixes for 3.0
 ------------------
 
--  Unlink raised an error if cache file did not exist when you try to delete it.
+-  Fixed a bug where ``unlink()`` raised an error if cache file did not exist when you try to delete it.
 -  Fixed a bug (#181) where a mis-spelling was in the form validation 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.
 -  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 (#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 a bug (#157, #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.
 -  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 (#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>.
+-  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 returning resource on ``db_pconnect()``.
 -  Fixed a bug in CI_Image_lib::gd_loaded() where it was possible for the script execution to end or a PHP E_WARNING message to be emitted.
--  In Pagination library, when use_page_numbers=TRUE previous link and page 1 link do not have the same url
+-  Fixed a bug in the :doc:`Pagination library <libraries/pagination>` where when use_page_numbers=TRUE previous link and page 1 link did not have the same url.
 -  Fixed a bug (#561) - Errors in :doc:`XML-RPC Library <libraries/xmlrpc>` were not properly escaped.
 -  Fixed a bug (#904) - ``CI_Loader::initialize()`` caused a PHP Fatal error to be triggered if error level E_STRICT is used.
--  Fixed a hosting edge case where an empty $_SERVER['HTTPS'] variable would evaluate to 'on'
+-  Fixed a hosting edge case where an empty $_SERVER['HTTPS'] variable would evaluate to 'on'.
 -  Fixed a bug (#154) - ``CI_Session::sess_update()`` caused the session to be destroyed on pages where multiple AJAX requests were executed at once.
 -  Fixed a possible bug in ``CI_Input::is_ajax_request()`` where some clients might not send the X-Requested-With HTTP header value exactly as 'XmlHttpRequest'.
 -  Fixed a bug (#1039) - MySQL's _backup() method failed due to a table name not being escaped.
@@ -180,7 +177,7 @@
 -  Fixed a bug (#129) - ODBC's num_rows() returned -1 in some cases, due to not all subdrivers supporting the odbc_num_rows() function.
 -  Fixed a bug (#153) - E_NOTICE being generated by getimagesize() in the :doc:`File Uploading Library <libraries/file_uploading>`.
 -  Fixed a bug (#611) - SQLSRV's error handling methods used to issue warnings when there's no actual error.
--  Fixed a bug (#1036) - is_write_type() method in the :doc:`Database Library <database/index>` didn't return TRUE for RENAME and OPTIMIZE queries.
+-  Fixed a bug (#1036) - is_write_type() method in the :doc:`Database Library <database/index>` didn't return TRUE for RENAME queries.
 -  Fixed a bug in PDO's _version() method where it used to return the client version as opposed to the server one.
 -  Fixed a bug in PDO's insert_id() method where it could've failed if it's used with Postgre versions prior to 8.1.
 -  Fixed a bug in CUBRID's affected_rows() method where a connection resource was passed to cubrid_affected_rows() instead of a result.
@@ -204,7 +201,7 @@
 -  Fixed a bug (#23, #1238) - delete_all() in the `Database Caching Library <database/caching>` used to delete .htaccess and index.html files, which is a potential security risk.
 -  Fixed a bug in :doc:`Trackback Library <libraries/trackback>` method validate_url() where it didn't actually do anything, due to input not being passed by reference.
 -  Fixed a bug (#11, #183, #863) - CI_Form_validation::_execute() silently continued to the next rule, if a rule method/function is not found.
--  Fixed a bug (#122) Where routed uri string was being reported incorrectly in sub-directories
+-  Fixed a bug (#122) Where routed uri string was being reported incorrectly in sub-directories.
 -  Fixed a bug (#1242) - read_dir() in the :doc:`Zip Library <libraries/zip>` wasn't compatible with Windows.
 -  Fixed a bug (#306) - ODBC driver didn't have an _insert_batch() method, which resulted in fatal error being triggered when insert_batch() is used with it.
 -  Fixed a bug in MSSQL and SQLSrv's _truncate() where the TABLE keyword was missing.
@@ -214,7 +211,9 @@
 -  Fixed a bug in SQLSRV's delete() method where like() and limit() conditions were ignored.
 -  Fixed a bug (#1265) - Database connections were always closed, regardless of the 'pconnect' option value.
 -  Fixed a bug (#128) - :doc:`Language Library <libraries/language>` did not correctly keep track of loaded language files.
--  Fixed a bug (#1242) Added Windows path compatibility to function read_dir of ZIP library
+-  Fixed a bug (#1242) - Added Windows path compatibility to function read_dir of ZIP library.
+-  Fixed a bug (#1314) - sess_destroy() did not destroy userdata.
+-  Fixed a bug (#1349) - get_extension() in the `File Uploading Library <libraries/file_uploading>` returned the original filename when it didn't have an actual extension.
 
 Version 2.1.1
 =============
@@ -237,7 +236,9 @@
 -  Fixed a bug - form_open() compared $action against site_url() instead of base_url().
 -  Fixed a bug - CI_Upload::_file_mime_type() could've failed if mime_content_type() is used for the detection and returns FALSE.
 -  Fixed a bug (#538) - Windows paths were ignored when using the :doc:`Image Manipulation Library <libraries/image_lib>` to create a new file.
--  Fixed a bug - When database caching was enabled, $this->db->query() checked the cache before binding variables which resulted in cached queries never being found
+-  Fixed a bug - When database caching was enabled, $this->db->query() checked the cache before binding variables which resulted in cached queries never being found.
+-  Fixed a bug - CSRF cookie value was allowed to be any (non-empty) string before being written to the output, making code injection a risk.
+-  Fixed a bug (#726) - PDO put a 'dbname' argument in it's connection string regardless of the database platform in use, which made it impossible to use SQLite.
 
 Version 2.1.0
 =============
diff --git a/user_guide_src/source/database/results.rst b/user_guide_src/source/database/results.rst
index 8653457..ac4fc37 100644
--- a/user_guide_src/source/database/results.rst
+++ b/user_guide_src/source/database/results.rst
@@ -136,6 +136,26 @@
 	| **$row = $query->next_row('array')**
 	| **$row = $query->previous_row('array')**
 
+.. note:: all the functions above will load the whole result into memory (prefetching) use unbuffered_row() for processing large result sets.
+
+unbuffered_row($type)
+=====
+
+This function returns a single result row without prefetching the whole result in memory as row() does.
+If your query has more than one row, it returns the current row and moves the internal data pointer ahead. 
+The result is returned as $type could be 'object' (default) or 'array' that will return an associative array.
+
+
+
+	$query = $this->db->query("YOUR QUERY");
+	
+	while ($row = $query->unbuffered_row())
+	{	
+		echo $row->title;
+		echo $row->name;
+		echo $row->body;
+	}
+
 ***********************
 Result Helper Functions
 ***********************
diff --git a/user_guide_src/source/installation/upgrade_200.rst b/user_guide_src/source/installation/upgrade_200.rst
index b39f4fd..29f44bd 100644
--- a/user_guide_src/source/installation/upgrade_200.rst
+++ b/user_guide_src/source/installation/upgrade_200.rst
@@ -87,7 +87,14 @@
 convention. Please update extended libraries to call
 parent::\__construct().
 
-Step 8: Update your user guide
+Step 8: Move any core extensions to application/core
+====================================================
+
+Any extensions to core classes (e.g. MY_Controller.php) in your
+application/libraries folder must be moved to the new 
+application/core folder.
+
+Step 9: Update your user guide
 ==============================
 
 Please replace your local copy of the user guide with the new version,
diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst
index e434e8d..63c4227 100644
--- a/user_guide_src/source/installation/upgrade_300.rst
+++ b/user_guide_src/source/installation/upgrade_300.rst
@@ -40,4 +40,9 @@
 
     $active_group = 'default';
     // $active_record = TRUE;
-    $query_builder = TRUE;
\ No newline at end of file
+    $query_builder = TRUE;
+    
+Step 5: Move your errors folder
+===============================
+
+In version 3.0.0, the errors folder has been moved from "application/errors" to "application/views/errors".
\ No newline at end of file