reverted changes from previous commit
diff --git a/.travis.yml b/.travis.yml
index 070b23c..ab0aa56 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,8 +14,7 @@
   - DB=pdo/sqlite
 
 before_script:
-  - curl -s http://getcomposer.org/installer | php
-  - php composer.phar install
+  - composer install --dev --no-progress
   - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS ci_test;' -U postgres; fi"
   - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'create database ci_test;' -U postgres; fi"
   - sh -c "if [ '$DB' = 'mysql' ] || [ '$DB' = 'mysqli' ] || [ '$DB' = 'pdo/mysql' ]; then mysql -e 'create database IF NOT EXISTS ci_test;'; fi"
diff --git a/application/config/mimes.php b/application/config/mimes.php
index 5b8ceff..6ff3812 100644
--- a/application/config/mimes.php
+++ b/application/config/mimes.php
@@ -58,7 +58,7 @@
 	'mif'	=>	'application/vnd.mif',
 	'xls'	=>	array('application/vnd.ms-excel', 'application/msexcel', 'application/x-msexcel', 'application/x-ms-excel', 'application/x-excel', 'application/x-dos_ms_excel', 'application/xls', 'application/x-xls', 'application/excel', 'application/download', 'application/vnd.ms-office', 'application/msword'),
 	'ppt'	=>	array('application/powerpoint', 'application/vnd.ms-powerpoint'),
-	'pptx'	=> 	'application/vnd.openxmlformats-officedocument.presentationml.presentation',
+	'pptx'	=> 	array('application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/x-zip', 'application/zip'),
 	'wbxml'	=>	'application/wbxml',
 	'wmlc'	=>	'application/wmlc',
 	'dcr'	=>	'application/x-director',
@@ -126,7 +126,7 @@
 	'docx'	=>	array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword', 'application/x-zip'),
 	'dot'	=>	array('application/msword', 'application/vnd.ms-office'),
 	'dotx'	=>	array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword'),
-	'xlsx'	=>	array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/zip', 'application/vnd.ms-excel', 'application/msword'),
+	'xlsx'	=>	array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/zip', 'application/vnd.ms-excel', 'application/msword', 'application/x-zip'),
 	'word'	=>	array('application/msword', 'application/octet-stream'),
 	'xl'	=>	'application/excel',
 	'eml'	=>	'message/rfc822',
diff --git a/composer.json b/composer.json
index 7d60020..e21aaed 100644
--- a/composer.json
+++ b/composer.json
@@ -1,8 +1,9 @@
 {
+    "name" : "ellislab/codeigniter",
     "require": {
-        "mikey179/vfsStream": "*"
+        "php": ">=5.2.4"
     },
     "require-dev": {
-		"phpunit/phpunit": "*"
-	}
+      "mikey179/vfsStream": "*"
+		}
 }
\ No newline at end of file
diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
index cb4b735..7f76977 100644
--- a/system/core/CodeIgniter.php
+++ b/system/core/CodeIgniter.php
@@ -263,7 +263,7 @@
 	$class  = $RTR->fetch_class();
 	$method = $RTR->fetch_method();
 
-	if ( ! class_exists($class) OR $method[0] === '_' OR method_exists('CI_Controller', $method))
+	if ( ! class_exists($class, FALSE) OR $method[0] === '_' OR method_exists('CI_Controller', $method))
 	{
 		if ( ! empty($RTR->routes['404_override']))
 		{
@@ -272,7 +272,7 @@
 				$method = 'index';
 			}
 
-			if ( ! class_exists($class))
+			if ( ! class_exists($class, FALSE))
 			{
 				if ( ! file_exists(APPPATH.'controllers/'.$class.'.php'))
 				{
@@ -310,7 +310,7 @@
 				$method = 'index';
 			}
 
-			if ( ! class_exists($class))
+			if ( ! class_exists($class, FALSE))
 			{
 				if ( ! file_exists(APPPATH.'controllers/'.$class.'.php'))
 				{
diff --git a/system/core/Common.php b/system/core/Common.php
index f8c1290..ee9bb2e 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -149,7 +149,7 @@
 			{
 				$name = $prefix.$class;
 
-				if (class_exists($name) === FALSE)
+				if (class_exists($name, FALSE) === FALSE)
 				{
 					require_once($path.$directory.'/'.$class.'.php');
 				}
@@ -163,7 +163,7 @@
 		{
 			$name = config_item('subclass_prefix').$class;
 
-			if (class_exists($name) === FALSE)
+			if (class_exists($name, FALSE) === FALSE)
 			{
 				require_once(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.'.php');
 			}
diff --git a/system/core/Hooks.php b/system/core/Hooks.php
index 17f6a02..b3b1119 100644
--- a/system/core/Hooks.php
+++ b/system/core/Hooks.php
@@ -195,7 +195,7 @@
 		// Call the requested class and/or function
 		if ($class !== FALSE)
 		{
-			if ( ! class_exists($class))
+			if ( ! class_exists($class, FALSE))
 			{
 				require($filepath);
 			}
diff --git a/system/core/Loader.php b/system/core/Loader.php
index 9306a09..d4e6323 100644
--- a/system/core/Loader.php
+++ b/system/core/Loader.php
@@ -270,7 +270,7 @@
 				continue;
 			}
 
-			if ($db_conn !== FALSE && ! class_exists('CI_DB'))
+			if ($db_conn !== FALSE && ! class_exists('CI_DB', FALSE))
 			{
 				if ($db_conn === TRUE)
 				{
@@ -280,7 +280,7 @@
 				$CI->load->database($db_conn, FALSE, TRUE);
 			}
 
-			if ( ! class_exists('CI_Model'))
+			if ( ! class_exists('CI_Model', FALSE))
 			{
 				load_class('Model', 'core');
 			}
@@ -459,7 +459,7 @@
 	 */
 	public function vars($vars = array(), $val = '')
 	{
-		if ($val !== '' && is_string($vars))
+		if (is_string($vars))
 		{
 			$vars = array($vars => $val);
 		}
@@ -1091,11 +1091,11 @@
 
 		if ($prefix === '')
 		{
-			if (class_exists('CI_'.$class))
+			if (class_exists('CI_'.$class, FALSE))
 			{
 				$name = 'CI_'.$class;
 			}
-			elseif (class_exists(config_item('subclass_prefix').$class))
+			elseif (class_exists(config_item('subclass_prefix').$class, FALSE))
 			{
 				$name = config_item('subclass_prefix').$class;
 			}
@@ -1110,7 +1110,7 @@
 		}
 
 		// Is the class name valid?
-		if ( ! class_exists($name))
+		if ( ! class_exists($name, FALSE))
 		{
 			log_message('error', 'Non-existent class: '.$name);
 			show_error('Non-existent class: '.$name);
diff --git a/system/core/Output.php b/system/core/Output.php
index a208414..25ecd49 100644
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -395,7 +395,7 @@
 		global $BM, $CFG;
 
 		// Grab the super object if we can.
-		if (class_exists('CI_Controller'))
+		if (class_exists('CI_Controller', FALSE))
 		{
 			$CI =& get_instance();
 		}
diff --git a/system/database/DB.php b/system/database/DB.php
index d910474..83d9733 100644
--- a/system/database/DB.php
+++ b/system/database/DB.php
@@ -149,7 +149,7 @@
 	if ( ! isset($query_builder) OR $query_builder === TRUE)
 	{
 		require_once(BASEPATH.'database/DB_query_builder.php');
-		if ( ! class_exists('CI_DB'))
+		if ( ! class_exists('CI_DB', FALSE))
 		{
 			/**
 			 * CI_DB
@@ -162,7 +162,7 @@
 			class CI_DB extends CI_DB_query_builder { }
 		}
 	}
-	elseif ( ! class_exists('CI_DB'))
+	elseif ( ! class_exists('CI_DB', FALSE))
 	{
 		/**
 	 	 * @ignore
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index 35ac8e8..ed0296d 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -625,7 +625,7 @@
 				// if transactions are enabled. If we don't call this here
 				// the error message will trigger an exit, causing the
 				// transactions to remain in limbo.
-				$this->trans_complete();
+				$this->_trans_depth > 0 && $this->trans_complete();
 
 				// Display errors
 				return $this->display_error(array('Error Number: '.$error['code'], $error['message'], $sql));
@@ -1560,7 +1560,7 @@
 	 */
 	protected function _cache_init()
 	{
-		if (class_exists('CI_DB_Cache'))
+		if (class_exists('CI_DB_Cache', FALSE))
 		{
 			if (is_object($this->CACHE))
 			{
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index c7bc4a6..85a233b 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -2627,6 +2627,7 @@
 		$this->_reset_run(array(
 			'qb_set'	=> array(),
 			'qb_from'	=> array(),
+			'qb_join'	=> array(),
 			'qb_where'	=> array(),
 			'qb_orderby'	=> array(),
 			'qb_keys'	=> array(),
diff --git a/system/database/DB_result.php b/system/database/DB_result.php
index a044fd5..41a8517 100644
--- a/system/database/DB_result.php
+++ b/system/database/DB_result.php
@@ -478,12 +478,9 @@
 			return NULL;
 		}
 
-		if (isset($result[$this->current_row + 1]))
-		{
-			++$this->current_row;
-		}
-
-		return $result[$this->current_row];
+		return isset($result[$this->current_row + 1])
+			? $result[++$this->current_row]
+			: NULL;
 	}
 
 	// --------------------------------------------------------------------
diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php
index 9822fda..9f953d4 100644
--- a/system/database/DB_utility.php
+++ b/system/database/DB_utility.php
@@ -238,7 +238,7 @@
 			$out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $name).$enclosure.$delim;
 		}
 
-		$out = rtrim($out).$newline;
+		$out = substr(rtrim($out), 0, -strlen($delim)).$newline;
 
 		// Next blast through the result array and build out the rows
 		while ($row = $query->unbuffered_row('array'))
@@ -247,7 +247,7 @@
 			{
 				$out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $item).$enclosure.$delim;
 			}
-			$out = rtrim($out).$newline;
+			$out = substr(rtrim($out), 0, -strlen($delim)).$newline;
 		}
 
 		return $out;
diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php
index 34adf0f..fa89661 100644
--- a/system/database/drivers/pdo/pdo_driver.php
+++ b/system/database/drivers/pdo/pdo_driver.php
@@ -49,13 +49,6 @@
 	public $dbdriver = 'pdo';
 
 	/**
-	 * Transaction enabled flag
-	 *
-	 * @var	bool
-	 */
-	public $trans_enabled = FALSE;
-
-	/**
 	 * PDO Options
 	 *
 	 * @var	array
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index 200da8a..692909c 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -228,7 +228,7 @@
 	 */
 	function form_upload($data = '', $value = '', $extra = '')
 	{
-		$default = array('type' => 'file', 'name' => '');
+		$defaults = array('type' => 'file', 'name' => '');
 		is_array($data) OR $data = array('name' => $data);
 		$data['type'] = 'file';
 		return '<input '._parse_form_attributes($data, $defaults).$extra." />\n";
@@ -642,37 +642,14 @@
 	 */
 	function set_value($field = '', $default = '', $is_textarea = FALSE)
 	{
-		if (FALSE !== ($OBJ =& _get_validation_object()) && $OBJ->has_rule($field))
+		if (FALSE === ($OBJ =& _get_validation_object()))
 		{
-			return form_prep($OBJ->set_value($field, $default), $is_textarea);
+			return isset($_POST[$field])
+				? form_prep($_POST[$field], $is_textarea)
+				: form_prep($default, $is_textarea);
 		}
 
-		// We couldn't find the $field in validator, so try in $_POST array
-		$index = $field;
-		$container = $_POST;
-		
-		// Test if the $field is an array name, and try to obtain the final index
-		if (preg_match_all('/\[(.*?)\]/', $field, $matches))
-		{
-			sscanf($field, '%[^[][', $index);
-			for ($i = 0, $c = count($matches[0]); $i < $c; $i++)
-			{
-				if (isset($container[$index]) && $matches[1][$i] !== '')
-				{
-					$container = $container[$index];
-					$index = $matches[1][$i];
-				}
-				else
-				{
-					$container = array();
-					break;
-				}
-			}
-		}
-
-		return isset($container[$index]) 
-			? form_prep($container[$index], $is_textarea)
-			: form_prep($default, $is_textarea);
+		return form_prep($OBJ->set_value($field, $default), $is_textarea);
 	}
 }
 
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 54db14f..b2351db 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -363,9 +363,9 @@
 	 */
 	function convert_accented_characters($str)
 	{
-		static $_foreign_characters;
+		static $array_from, $array_to;
 
-		if ( ! is_array($_foreign_characters))
+		if ( ! is_array($array_from))
 		{
 			if (file_exists(APPPATH.'config/foreign_chars.php'))
 			{
@@ -379,14 +379,17 @@
 
 			if (empty($foreign_characters) OR ! is_array($foreign_characters))
 			{
-				$_foreign_characters = array();
+				$array_from = array();
+				$array_to = array();
+
 				return $str;
 			}
 
-			$_foreign_characters = $foreign_characters;
+			$array_from = array_keys($foreign_characters);
+			$array_to = array_values($foreign_characters);
 		}
 
-		return preg_replace(array_keys($_foreign_characters), array_values($_foreign_characters), $str);
+		return preg_replace($array_from, $array_to, $str);
 	}
 }
 
diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php
index 8096b26..246a7a2 100644
--- a/system/libraries/Cache/drivers/Cache_memcached.php
+++ b/system/libraries/Cache/drivers/Cache_memcached.php
@@ -182,11 +182,11 @@
 			}
 		}
 
-		if (class_exists('Memcached'))
+		if (class_exists('Memcached', FALSE))
 		{
 			$this->_memcached = new Memcached();
 		}
-		elseif (class_exists('Memcache'))
+		elseif (class_exists('Memcache', FALSE))
 		{
 			$this->_memcached = new Memcache();
 		}
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 0319ac5..daa3848 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -94,7 +94,7 @@
 	 * @var	int
 	 */
 	public $smtp_timeout	= 5;
-	
+
 	/**
 	 * SMTP persistent connection
 	 *
@@ -408,7 +408,7 @@
 	}
 
 	// --------------------------------------------------------------------
-	
+
 	/**
 	 * Destructor - Releases Resources
 	 *
@@ -2021,7 +2021,7 @@
 		{
 			return TRUE;
 		}
-			
+
 		if (strpos($reply, '334') !== 0)
 		{
 			$this->_set_error_message('lang:email_failed_smtp_login', $reply);
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index 1ed5084..172e799 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -836,21 +836,6 @@
 	// --------------------------------------------------------------------
 
 	/**
-	 * Checks if the rule is present within the validator
-	 *
-	 * Permits you to check if a rule is present within the validator
-	 *
-	 * @param	string	the field name
-	 * @return	bool
-	 */
-	public function has_rule($field)
-	{
-		return isset($this->_field_data[$field]);
-	}
-
-	// --------------------------------------------------------------------
-
-	/**
 	 * Get the value from a form
 	 *
 	 * Permits you to repopulate a form field with the value it was submitted
diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php
index b673e9c..cc6fe48 100644
--- a/system/libraries/Migration.php
+++ b/system/libraries/Migration.php
@@ -228,7 +228,7 @@
 			$class = 'Migration_'.ucfirst(strtolower($this->_get_migration_name(basename($file, '.php'))));
 
 			// Validate the migration file structure
-			if ( ! class_exists($class))
+			if ( ! class_exists($class, FALSE))
 			{
 				$this->_error_string = sprintf($this->lang->line('migration_class_doesnt_exist'), $class);
 				return FALSE;
diff --git a/system/libraries/Session/drivers/Session_cookie.php b/system/libraries/Session/drivers/Session_cookie.php
index 11bb32f..0e86441 100644
--- a/system/libraries/Session/drivers/Session_cookie.php
+++ b/system/libraries/Session/drivers/Session_cookie.php
@@ -494,7 +494,7 @@
 		$this->userdata = array(
 			'session_id'	=> $this->_make_sess_id(),
 			'ip_address'	=> $this->CI->input->ip_address(),
-			'user_agent'	=> substr($this->CI->input->user_agent(), 0, 120),
+			'user_agent'	=> trim(substr($this->CI->input->user_agent(), 0, 120)),
 			'last_activity'	=> $this->now,
 		);
 
@@ -602,6 +602,9 @@
 				$set['user_data'] = $this->_serialize($userdata);
 			}
 
+			// Reset query builder values.
+			$this->CI->db->reset_query();
+
 			// Run the update query
 			// Any time we change the session id, it gets updated immediately,
 			// so our where clause below is always safe
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index acd76b0..1c14f99 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -1212,7 +1212,7 @@
 		 * Notes:
 		 *	- the DIRECTORY_SEPARATOR comparison ensures that we're not on a Windows system
 		 *	- many system admins would disable the exec(), shell_exec(), popen() and similar functions
-		 *	  due to security concerns, hence the function_exists() checks
+		 *	  due to security concerns, hence the function_usable() checks
 		 */
 		if (DIRECTORY_SEPARATOR !== '\\')
 		{
@@ -1223,7 +1223,7 @@
 			if (function_usable('exec'))
 			{
 				/* This might look confusing, as $mime is being populated with all of the output when set in the second parameter.
-				 * However, we only neeed the last line, which is the actual return value of exec(), and as such - it overwrites
+				 * However, we only need the last line, which is the actual return value of exec(), and as such - it overwrites
 				 * anything that could already be set for $mime previously. This effectively makes the second parameter a dummy
 				 * value, which is only put to allow us to get the return status code.
 				 */
diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php
index d4524d2..d263d78 100644
--- a/system/libraries/Xmlrpcs.php
+++ b/system/libraries/Xmlrpcs.php
@@ -31,7 +31,7 @@
 	show_error('Your PHP installation does not support XML');
 }
 
-if ( ! class_exists('CI_Xmlrpc'))
+if ( ! class_exists('CI_Xmlrpc', FALSE))
 {
 	show_error('You must load the Xmlrpc class before loading the Xmlrpcs class in order to create a server.');
 }
diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php
index ca1c6df..5cf25fe 100644
--- a/tests/codeigniter/core/Input_test.php
+++ b/tests/codeigniter/core/Input_test.php
@@ -95,8 +95,8 @@
 	public function test_cookie()
 	{
 		$_COOKIE['foo'] = 'bar';
-
 		$this->assertEquals('bar', $this->input->cookie('foo'));
+		$this->assertNull($this->input->cookie('bar'));
 	}
 
 	// --------------------------------------------------------------------
@@ -138,4 +138,27 @@
 		}
 	}
 
+	// --------------------------------------------------------------------
+
+	public function test_method()
+	{
+		$_SERVER['REQUEST_METHOD'] = 'GET';
+		$this->assertEquals('get', $this->input->method());
+		$this->assertEquals('GET', $this->input->method(TRUE));
+		$_SERVER['REQUEST_METHOD'] = 'POST';
+		$this->assertEquals('post', $this->input->method());
+		$this->assertEquals('POST', $this->input->method(TRUE));
+	}
+
+	// --------------------------------------------------------------------
+
+	public function test_is_ajax_request()
+	{
+		$this->assertFalse($this->input->is_ajax_request());
+		$_SERVER['HTTP_X_REQUESTED_WITH'] = 'test';
+		$this->assertFalse($this->input->is_ajax_request());
+		$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
+		$this->assertTrue($this->input->is_ajax_request());
+	}
+
 }
\ No newline at end of file
diff --git a/tests/codeigniter/core/Output_test.php b/tests/codeigniter/core/Output_test.php
index 728df3b..0eeb93f 100644
--- a/tests/codeigniter/core/Output_test.php
+++ b/tests/codeigniter/core/Output_test.php
@@ -3,6 +3,16 @@
 class Output_test extends CI_TestCase {
 
 	public $output;
+	protected $_output_data = <<<HTML
+<html>
+	<head>
+		<title>Basic HTML</title>
+	</head>
+	<body>
+		Test
+	</body>
+</html>
+HTML;
 
 	public function set_up()
 	{
@@ -13,6 +23,31 @@
 
 	// --------------------------------------------------------------------
 
+	public function test_set_get_append_output()
+	{
+		$append = "<!-- comment /-->\n";
+
+		$this->assertEquals(
+			$this->_output_data.$append,
+			$this->output
+				->set_output($this->_output_data)
+				->append_output("<!-- comment /-->\n")
+				->get_output()
+		);
+	}
+
+	// --------------------------------------------------------------------
+
+	public function test_minify()
+	{
+		$this->assertEquals(
+			str_replace(array("\t", "\n"), '', $this->_output_data),
+			$this->output->minify($this->_output_data)
+		);
+	}
+
+	// --------------------------------------------------------------------
+
 	public function test_get_content_type()
 	{
 		$this->assertEquals('text/html', $this->output->get_content_type());
diff --git a/tests/codeigniter/core/Utf8_test.php b/tests/codeigniter/core/Utf8_test.php
new file mode 100644
index 0000000..caa7b69
--- /dev/null
+++ b/tests/codeigniter/core/Utf8_test.php
@@ -0,0 +1,20 @@
+<?php
+
+class Utf8_test extends CI_TestCase {
+
+	public function set_up()
+	{
+		$this->utf8 = new Mock_Core_Utf8();
+	}
+
+	// --------------------------------------------------------------------
+
+	public function test_convert_to_utf8()
+	{
+		$this->assertEquals(
+			$this->utf8->convert_to_utf8('òåñò', 'WINDOWS-1251'),
+			'ั‚ะตัั‚'
+		);
+	}
+
+}
\ No newline at end of file
diff --git a/tests/codeigniter/helpers/form_helper_test.php b/tests/codeigniter/helpers/form_helper_test.php
index 8916527..e234f9c 100644
--- a/tests/codeigniter/helpers/form_helper_test.php
+++ b/tests/codeigniter/helpers/form_helper_test.php
@@ -58,7 +58,7 @@
 	public function test_form_upload()
 	{
 		$expected = <<<EOH
-<input type="file" name="attachment" value=""  />
+<input type="file" name="attachment"  />
 
 EOH;
 
diff --git a/tests/mocks/database/ci_test.sqlite b/tests/mocks/database/ci_test.sqlite
index 44dcef9..574d3ae 100755
--- a/tests/mocks/database/ci_test.sqlite
+++ b/tests/mocks/database/ci_test.sqlite
Binary files differ
diff --git a/tests/mocks/libraries/session.php b/tests/mocks/libraries/session.php
index 562033b..adbecb3 100644
--- a/tests/mocks/libraries/session.php
+++ b/tests/mocks/libraries/session.php
@@ -33,4 +33,6 @@
 			$_COOKIE[$name] = $value;
 		}
 	}
-}
\ No newline at end of file
+}
+
+class Mock_Libraries_Session_native extends CI_Session_native {}
\ No newline at end of file
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 2c2da6a..07dae1f 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -60,12 +60,11 @@
 -  Helpers
 
    -  :doc:`Date Helper <helpers/date_helper>` changes include:
-	 - ``now()`` now works with all timezone strings supported by PHP.
-	 - Added an optional third parameter to ``timespan()`` that constrains the number of time units displayed.
-	 - Added an optional parameter to ``timezone_menu()`` that allows more attributes to be added to the generated select tag.
+	 - :php:func:`now()` now works with all timezone strings supported by PHP.
+	 - Added an optional third parameter to :php:func:`timespan()` that constrains the number of time units displayed.
+	 - Added an optional parameter to :php:func:`timezone_menu()` that allows more attributes to be added to the generated select tag.
 	 - Deprecated ``standard_date()``, which now just uses the native ``date()`` with `DateTime constants <http://www.php.net/manual/en/class.datetime.php#datetime.constants.types>`_.
-	 - Added function ``date_range()`` that generates a list of dates between a specified period.
-   -  ``create_captcha()`` accepts additional colors parameter, allowing for color customization.
+	 - Added function :php:func:`date_range()` that generates a list of dates between a specified period.
    -  :doc:`URL Helper <helpers/url_helper>` changes include:
 	 - Deprecated *separator* options **dash** and **underscore** for function :php:func:`url_title()` (they are only aliases for '-' and '_' respectively).
 	 - :php:func:`url_title()` will now trim extra dashes from beginning and end.
@@ -244,7 +243,6 @@
 	 -  Added support for named parameters in error messages.
 	 -  :doc:`Language <libraries/language>` line keys must now be prefixed with **form_validation_**.
 	 -  Added rule **alpha_numeric_spaces**.
-	 -  Added method ``has_rule()`` to determine if a rule exists.
    -  Added support for setting :doc:`Table <libraries/table>` class defaults in a config file.
    -  :doc:`Caching Library <libraries/caching>` changes include:
 	 -  Added Wincache driver.
@@ -341,16 +339,15 @@
 
 -  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 Query Builder nested transactions because _trans_depth was not getting incremented.
+-  Fixed a bug (#159, #163) - :doc:`Query Builder <database/query_builder>` nested transactions didn't work properly due to ``_trans_depth`` not being incremented.
 -  Fixed a bug (#737, #75) - :doc:`Pagination <libraries/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 (#419) - :php:func:`auto_link()` didn't recognize URLs that come after a word boundary.
 -  Fixed a bug (#724) - :doc:`Form Validation Library <libraries/form_validation>` rule **is_unique** didn't check if a database connection exists.
 -  Fixed a bug (#647) - :doc:`Zip Library <libraries/zip>` internal method ``_get_mod_time()`` didn't suppress possible "stat failed" errors generated by ``filemtime()``.
--  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 (#157, #174) - :doc:`Image Manipulation Library <libraries/image_lib>` method ``clear()`` didn't completely clear properties.
+-  Fixed a bug where :doc:`Database Forge <database/forge>` method ``create_table()`` with PostgreSQL database could lead to fetching the whole table.
+-  Fixed a bug (#795) - :doc:`Form Helper <helpers/form_helper>` :php:func:`form_open()` didn't add the default form *method* and *accept-charset* when an empty array is passed to it.
+-  Fixed a bug (#797) - :php:func:`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 returning resource on ``db_pconnect()``.
@@ -464,7 +461,7 @@
 -  Fixed a bug (#1255) - :doc:`User Agent Library <libraries/user_agent>` method ``is_referral()`` only checked if ``$_SERVER['HTTP_REFERER']`` exists.
 -  Fixed a bug (#1146) - :doc:`Download Helper <helpers/download_helper>` function ``force_download()`` incorrectly sent *Cache-Control* directives *pre-check* and *post-check* to Internet Explorer.
 -  Fixed a bug (#1811) - :doc:`URI Library <libraries/uri>` didn't properly cache segments for ``uri_to_assoc()`` and ``ruri_to_assoc()``.
--  Fixed a bug (#1506) - :doc:`Form Helper <helpers/form_helper>` set empty *name* attributes.
+-  Fixed a bug (#1506) - :doc:`Form Helpers <helpers/form_helper>` set empty *name* attributes.
 -  Fixed a bug (#59) - :doc:`Query Builder <database/query_builder>` method ``count_all_results()`` ignored the DISTINCT clause.
 -  Fixed a bug (#1624) - :doc:`Form Validation Library <libraries/form_validation>` rule **matches** didn't property handle array field names.
 -  Fixed a bug (#1630) - :doc:`Form Helper <helpers/form_helper>` function ``set_value()`` didn't escape HTML entities.
@@ -487,9 +484,10 @@
 -  Fixed a bug - :doc:`DB result <database/results>` method ``list_fields()`` didn't reset its field pointer for the *mysql*, *mysqli* and *mssql* drivers.
 -  Fixed a bug (#73) - :doc:`Security Library <libraries/security>` method ``sanitize_filename()`` could be tricked by an XSS attack.
 -  Fixed a bug (#2211) - :doc:`Migration Library <libraries/migration>` extensions couldn't execute ``CI_Migration::__construct()``.
--  Fixed a bug (#2255) where ``smtp_timeout`` was not being applied to read and writes for the socket.
--  Fixed a bug (#2239) of missing subject when using ``bcc_batch_mode``.
--  Fixed a bug (#2236) - :doc:`Form Helper <helpers/form_helper>` incorrectly determined the value to return in method ``set_value()``.
+-  Fixed a bug (#2255) - :doc:`Email Library <libraries/email>` didn't apply ``smtp_timeout``to socket reads and writes.
+-  Fixed a bug (#2239) - :doc:`Email Library <libraries/email>` improperly handled the Subject when used with ``bcc_batch_mode`` resulting in E_WARNING messages and an empty Subject.
+-  Fixed a bug (#2234) - :doc:`Query Builder <database/query_builder>` didn't reset JOIN cache for write-type queries.
+-  Fixed a bug (#2298) - :doc:`Database Results <database/results>` method `next_row()` kept returning the last row, allowing for infinite loops.
 
 Version 2.1.3
 =============
diff --git a/user_guide_src/source/general/styleguide.rst b/user_guide_src/source/general/styleguide.rst
index 99bc056..144b362 100644
--- a/user_guide_src/source/general/styleguide.rst
+++ b/user_guide_src/source/general/styleguide.rst
@@ -3,8 +3,10 @@
 ###############
 
 
-The following page describes the use of coding rules adhered to when
-developing CodeIgniter.
+The following page describes the coding styles adhered to when
+contributing to the development of CodeIgniter. There is no requirement
+to use these styles in your own CodeIgniter application, though they
+are recommended.
 
 .. contents:: Table of Contents
 
@@ -72,14 +74,15 @@
 	/* End of file myfile.php */
 	/* Location: ./system/modules/mymodule/myfile.php */
 
+.. note:: There should be no empty line or newline character(s) following
+	the closing comments. If you happen to see one when
+	submitting a pull request, please check your IDE settings and fix it.
+
 Class and Method Naming
 =======================
 
 Class names should always start with an uppercase letter. Multiple words
-should be separated with an underscore, and not CamelCased. All other
-class methods should be entirely lowercased and named to clearly
-indicate their function, preferably including a verb. Try to avoid
-overly long and verbose names.
+should be separated with an underscore, and not CamelCased.
 
 **INCORRECT**::
 
@@ -100,7 +103,10 @@
 		}
 	}
 
-Examples of improper and proper method naming:
+Class methods should be entirely lowercased and named to clearly
+indicate their function, preferably including a verb. Try to avoid
+overly long and verbose names. Multiple words should be separated
+with an underscore.
 
 **INCORRECT**::
 
@@ -117,8 +123,8 @@
 Variable Names
 ==============
 
-The guidelines for variable naming is very similar to that used for
-class methods. Namely, variables should contain only lowercase letters,
+The guidelines for variable naming are very similar to those used for
+class methods. Variables should contain only lowercase letters,
 use underscore separators, and be reasonably named to indicate their
 purpose and contents. Very short, non-word variables should only be used
 as iterators in for() loops.
@@ -242,10 +248,10 @@
 Logical Operators
 =================
 
-Use of **\|\|** is discouraged as its clarity on some output devices is
-low (looking like the number 11 for instance). **&&** is preferred over
-**AND** but either are acceptable, and a space should always precede and
-follow **!**.
+Use of the ``||`` "or" comparison operator is discouraged, as its clarity
+on some output devices is low (looking like the number 11, for instance).
+``&&`` is preferred over ``AND`` but either are acceptable, and a space should
+always precede and follow ``!``.
 
 **INCORRECT**::
 
@@ -318,14 +324,9 @@
 Debugging Code
 ==============
 
-No debugging code can be left in place for submitted add-ons unless it
-is commented out, i.e. no var_dump(), print_r(), die(), and exit()
-calls that were used while creating the add-on, unless they are
-commented out.
-
-::
-
-	// print_r($foo);
+Do not leave debugging code in your submissions, even when commented out.
+Things such as ``var_dump()``, ``print_r()``, ``die()``/``exit()`` should not be included
+in your code unless it serves a specific purpose other than debugging.
 
 Whitespace in Files
 ===================
@@ -333,73 +334,26 @@
 No whitespace can precede the opening PHP tag or follow the closing PHP
 tag. Output is buffered, so whitespace in your files can cause output to
 begin before CodeIgniter outputs its content, leading to errors and an
-inability for CodeIgniter to send proper headers. In the examples below,
-select the text with your mouse to reveal the incorrect whitespace.
+inability for CodeIgniter to send proper headers.
 
 Compatibility
 =============
 
-Unless specifically mentioned in your add-on's documentation, all code
-must be compatible with PHP version 5.1+. Additionally, do not use PHP
-functions that require non-default libraries to be installed unless your
-code contains an alternative method when the function is not available,
-or you implicitly document that your add-on requires said PHP libraries.
+CodeIgniter requires a minimum PHP version of 5.2.4. Your code must either
+be compatible with this minimum requirement, provide a suitable fallback,
+or be an optional feature that dies quietly without affecting a user's
+application.
 
-Class and File Names using Common Words
-=======================================
-
-When your class or filename is a common word, or might quite likely be
-identically named in another PHP script, provide a unique prefix to help
-prevent collision. Always realize that your end users may be running
-other add-ons or third party PHP scripts. Choose a prefix that is unique
-to your identity as a developer or company.
-
-**INCORRECT**::
-
-	class Email		pi.email.php
-	class Xml		ext.xml.php
-	class Import	mod.import.php
-
-**CORRECT**::
-
-	class Pre_email		pi.pre_email.php
-	class Pre_xml		ext.pre_xml.php
-	class Pre_import	mod.pre_import.php
-
-Database Table Names
-====================
-
-Any tables that your add-on might use must use the 'exp\_' prefix,
-followed by a prefix uniquely identifying you as the developer or
-company, and then a short descriptive table name. You do not need to be
-concerned about the database prefix being used on the user's
-installation, as CodeIgniter's database class will automatically convert
-'exp\_' to what is actually being used.
-
-**INCORRECT**::
-
-	email_addresses		// missing both prefixes
-	pre_email_addresses	// missing exp_ prefix
-	exp_email_addresses	// missing unique prefix
-
-**CORRECT**::
-
-	exp_pre_email_addresses
-
-.. note:: Be mindful that MySQL has a limit of 64 characters for table
-	names. This should not be an issue as table names that would exceed this
-	would likely have unreasonable names. For instance, the following table
-	name exceeds this limitation by one character. Silly, no?
-	**exp_pre_email_addresses_of_registered_users_in_seattle_washington**
+Additionally, do not use PHP functions that require non-default libraries
+to be installed unless your code contains an alternative method when the
+function is not available.
 
 One File per Class
 ==================
 
-Use separate files for each class your add-on uses, unless the classes
-are *closely related*. An example of CodeIgniter files that contains
-multiple classes is the Database class file, which contains both the DB
-class and the DB_Cache class, and the Magpie plugin, which contains
-both the Magpie and Snoopy classes.
+Use separate files for each class, unless the classes are *closely related*.
+An example of a CodeIgniter file that contains multiple classes is the 
+Xmlrpc library file.
 
 Whitespace
 ==========
@@ -536,8 +490,8 @@
 Localized Text
 ==============
 
-Any text that is output in the control panel should use language
-variables in your lang file to allow localization.
+CodeIgniter libraries should take advantage of corresponding language files
+whenever possible.
 
 **INCORRECT**::
 
@@ -550,7 +504,7 @@
 Private Methods and Variables
 =============================
 
-Methods and variables that are only accessed internally by your class,
+Methods and variables that are only accessed internally,
 such as utility and helper functions that your public methods use for
 code abstraction, should be prefixed with an underscore.
 
@@ -567,7 +521,7 @@
 that you did not set yourself (such as ``$_POST`` array keys) without first
 checking to see that it ``isset()``.
 
-Make sure that while developing your add-on, error reporting is enabled
+Make sure that your dev environment has error reporting enabled
 for ALL users, and that display_errors is enabled in the PHP
 environment. You can check this setting with::
 
diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst
index a3ea01d..02841ab 100644
--- a/user_guide_src/source/installation/upgrade_300.rst
+++ b/user_guide_src/source/installation/upgrade_300.rst
@@ -1,5 +1,5 @@
 #############################
-Upgrading from 2.1.2 to 3.0.0
+Upgrading from 2.1.3 to 3.0.0
 #############################
 
 .. note:: These upgrade notes are for a version that is yet to be released.
@@ -104,9 +104,9 @@
 	(.+)	// matches ANYTHING
 	(:any)	// matches any character, except for '/'
 
-*******************************************
-Step 9: Update your librararies' file names
-*******************************************
+*****************************************
+Step 9: Update your libraries' file names
+*****************************************
 
 CodeIgniter 3.0 only allows library file names to be named in a *ucfirst* manner
 (meaning that the first letter of the class name must be a capital). For example,
@@ -136,8 +136,15 @@
 The default return value of these functions, when the required elements
 don't exist, has been changed from FALSE to NULL.
 
+***********************************************************************
+Step 11: Check the calls to Directory Helper's directory_map() function
+***********************************************************************
+
+In the resulting array, directories now end with a trailing directory
+separator (i.e. a slash, usually).
+
 *************************************************************
-Step 11: Update usage of Database Forge's drop_table() method
+Step 12: Update usage of Database Forge's drop_table() method
 *************************************************************
 
 Up until now, ``drop_table()`` added an IF EXISTS clause by default or it didn't work
@@ -159,7 +166,7 @@
 	all drivers with the exception of ODBC.
 
 ***********************************************************
-Step 12: Change usage of Email library with multiple emails
+Step 13: Change usage of Email library with multiple emails
 ***********************************************************
 
 The :doc:`Email Library <../libraries/email>` will automatically clear the
@@ -174,7 +181,7 @@
  	}
 
 ***************************************************
-Step 13: Update your Form_validation language lines
+Step 14: Update your Form_validation language lines
 ***************************************************
 
 Two improvements have been made to the :doc:`Form Validation Library
@@ -205,7 +212,7 @@
 	later.
 
 ****************************************************************
-Step 14: Remove usage of (previously) deprecated functionalities
+Step 15: Remove usage of (previously) deprecated functionalities
 ****************************************************************
 
 In addition to the ``$autoload['core']`` configuration setting, there's a
@@ -238,7 +245,7 @@
 :doc:`Security Helper <../helpers/security_helper>` function ``do_hash()`` is now just an alias for
 PHP's native ``hash()`` function. It is deprecated and scheduled for removal in CodeIgniter 3.1+.
 
-.. note:: This function is still available, but you're strongly encouraged to remove it's usage sooner
+.. note:: This function is still available, but you're strongly encouraged to remove its usage sooner
 	rather than later.
 
 File helper read_file()
@@ -248,7 +255,7 @@
 PHP's native ``file_get_contents()`` function. It is deprecated and scheduled for removal in
 CodeIgniter 3.1+.
 
-.. note:: This function is still available, but you're strongly encouraged to remove it's usage sooner
+.. note:: This function is still available, but you're strongly encouraged to remove its usage sooner
 	rather than later.
 
 String helper repeater()
@@ -257,7 +264,7 @@
 :doc:`String Helper <../helpers/string_helper>` function :php:func:`repeater()` is now just an alias for
 PHP's native ``str_repeat()`` function. It is deprecated and scheduled for removal in CodeIgniter 3.1+.
 
-.. note:: This function is still available, but you're strongly encouraged to remove it's usage sooner
+.. note:: This function is still available, but you're strongly encouraged to remove its usage sooner
 	rather than later.
 
 String helper trim_slashes()
@@ -267,7 +274,7 @@
 for PHP's native ``trim()`` function (with a slash passed as its second argument). It is deprecated and
 scheduled for removal in CodeIgniter 3.1+.
 
-.. note:: This function is still available, but you're strongly encouraged to remove it's usage sooner
+.. note:: This function is still available, but you're strongly encouraged to remove its usage sooner
 	rather than later.
 
 Email helper functions
@@ -292,7 +299,7 @@
 to the availability of native PHP `constants <http://www.php.net/manual/en/class.datetime.php#datetime.constants.types>`_,
 which when combined with ``date()`` provide the same functionality. Furthermore, they have the
 exact same names as the ones supported by ``standard_date()``. Here are examples of how to replace
-it's usage:
+its usage:
 
 ::
 
@@ -308,7 +315,7 @@
 	// Replacement
 	date(DATE_ATOM, $time);
 
-.. note:: This function is still available, but you're strongly encouraged to remove its' usage sooner
+.. note:: This function is still available, but you're strongly encouraged to remove its usage sooner
 	rather than later as it is scheduled for removal in CodeIgniter 3.1+.
 
 Pagination library 'anchor_class' setting
@@ -320,7 +327,7 @@
 As a result of that, the 'anchor_class' setting is now deprecated and scheduled for removal in
 CodeIgniter 3.1+.
 
-.. note:: This setting is still available, but you're strongly encouraged to remove its' usage sooner
+.. note:: This setting is still available, but you're strongly encouraged to remove its usage sooner
 	rather than later.
 
 String helper random_string() types 'unique' and 'encrypt'
diff --git a/user_guide_src/source/libraries/migration.rst b/user_guide_src/source/libraries/migration.rst
index 9a7b10d..b734f5c 100644
--- a/user_guide_src/source/libraries/migration.rst
+++ b/user_guide_src/source/libraries/migration.rst
@@ -10,7 +10,7 @@
 
 The database table **migration** tracks which migrations have already been 
 run so all you have to do is update your application files and 
-call **$this->migrate->current()** to work out which migrations should be run. 
+call **$this->migration->current()** to work out which migrations should be run. 
 The current version is found in **config/migration.php**.
 
 ********************
diff --git a/user_guide_src/source/tutorial/news_section.rst b/user_guide_src/source/tutorial/news_section.rst
index 833e34e..d7754e9 100644
--- a/user_guide_src/source/tutorial/news_section.rst
+++ b/user_guide_src/source/tutorial/news_section.rst
@@ -162,7 +162,7 @@
 news items is still absent. The model created earlier is made in such
 way that it can easily be used for this functionality. You only need to
 add some code to the controller and create a new view. Go back to the
-news controller and add the following lines to the file.
+news controller and update ``view()`` with the following:
 
 ::
 
@@ -211,4 +211,4 @@
 	$route['default_controller'] = 'pages/view';
 
 Point your browser to your document root, followed by index.php/news and
-watch your news page.
\ No newline at end of file
+watch your news page.