Don't use globals

- Use load_class() to get objects during bootstrap process.
- Change load_class() to accept a class constructor parameter
  instead of previously unused class name prefix.
- Change CI_Router::__construct() to accept  as a parameter.
diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
index 6d67471..df5fa3b 100644
--- a/system/core/CodeIgniter.php
+++ b/system/core/CodeIgniter.php
@@ -212,7 +212,7 @@
  *  Instantiate the routing class and set the routing
  * ------------------------------------------------------
  */
-	$RTR =& load_class('Router', 'core');
+	$RTR =& load_class('Router', 'core', isset($routing) ? $routing : NULL);
 
 /*
  * ------------------------------------------------------
@@ -226,8 +226,7 @@
  *	Is there a valid cache file? If so, we're done...
  * ------------------------------------------------------
  */
-	if ($EXT->call_hook('cache_override') === FALSE
-		&& $OUT->_display_cache($CFG, $URI) === TRUE)
+	if ($EXT->call_hook('cache_override') === FALSE && $OUT->_display_cache($CFG, $URI) === TRUE)
 	{
 		exit;
 	}
diff --git a/system/core/Common.php b/system/core/Common.php
index 0ea53c4..24315a0 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -130,7 +130,7 @@
 	 * @param	string	the class name prefix
 	 * @return	object
 	 */
-	function &load_class($class, $directory = 'libraries', $prefix = 'CI_')
+	function &load_class($class, $directory = 'libraries', $param = NULL)
 	{
 		static $_classes = array();
 
@@ -148,7 +148,7 @@
 		{
 			if (file_exists($path.$directory.'/'.$class.'.php'))
 			{
-				$name = $prefix.$class;
+				$name = 'CI_'.$class;
 
 				if (class_exists($name, FALSE) === FALSE)
 				{
@@ -166,7 +166,7 @@
 
 			if (class_exists($name, FALSE) === FALSE)
 			{
-				require_once(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.'.php');
+				require_once(APPPATH.$directory.'/'.$name.'.php');
 			}
 		}
 
@@ -183,8 +183,9 @@
 		// Keep track of what we just loaded
 		is_loaded($class);
 
-		$_classes[$class] = new $name();
-		return $_classes[$class];
+		return $_classes[$class] = isset($param)
+			? new $name($param)
+			: new $name();
 	}
 }
 
diff --git a/system/core/Input.php b/system/core/Input.php
index fdb308b..620e50f 100644
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -126,14 +126,12 @@
 		$this->_enable_csrf		= (config_item('csrf_protection') === TRUE);
 		$this->_sandardize_newlines	= (bool) config_item('standardize_newlines');
 
-		global $SEC;
-		$this->security =& $SEC;
+		$this->security =& load_class('Security', 'core');
 
 		// Do we need the UTF-8 class?
 		if (UTF8_ENABLED === TRUE)
 		{
-			global $UNI;
-			$this->uni =& $UNI;
+			$this->uni =& load_class('Utf8', 'core');
 		}
 
 		// Sanitize global arrays
diff --git a/system/core/Output.php b/system/core/Output.php
index e8c1c39..2811a73 100644
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -401,10 +401,11 @@
 	 */
 	public function _display($output = '')
 	{
-		// Note:  We use globals because we can't use $CI =& get_instance()
+		// Note:  We use load_class() because we can't use $CI =& get_instance()
 		// since this function is sometimes called by the caching mechanism,
 		// which happens before the CI super object is available.
-		global $BM, $CFG;
+		$BM =& load_class('Benchmark', 'core');
+		$CFG =& load_class('Config', 'core');
 
 		// Grab the super object if we can.
 		if (class_exists('CI_Controller', FALSE))
diff --git a/system/core/Router.php b/system/core/Router.php
index 05263b1..2448d9c 100644
--- a/system/core/Router.php
+++ b/system/core/Router.php
@@ -109,10 +109,8 @@
 	 *
 	 * @return	void
 	 */
-	public function __construct()
+	public function __construct($routing = NULL)
 	{
-		global $routing;
-
 		$this->config =& load_class('Config', 'core');
 		$this->uri =& load_class('URI', 'core');
 
@@ -120,7 +118,7 @@
 		$this->_set_routing();
 
 		// Set any routing overrides that may exist in the main index file
-		if (isset($routing) && is_array($routing))
+		if (is_array($routing))
 		{
 			if (isset($routing['directory']))
 			{
diff --git a/system/core/URI.php b/system/core/URI.php
index 5f5a9ce..9a545fd 100644
--- a/system/core/URI.php
+++ b/system/core/URI.php
@@ -628,9 +628,7 @@
 	 */
 	public function ruri_string()
 	{
-		global $RTR;
-
-		return ltrim($RTR->directory, '/').implode('/', $this->rsegments);
+		return ltrim(load_class('Router', 'core')->directory, '/').implode('/', $this->rsegments);
 	}
 
 }
diff --git a/tests/mocks/core/common.php b/tests/mocks/core/common.php
index 9eb6b09..5c32ca5 100644
--- a/tests/mocks/core/common.php
+++ b/tests/mocks/core/common.php
@@ -65,6 +65,7 @@
 
 // --------------------------------------------------------------------
 
+/*
 if ( ! function_exists('load_class'))
 {
 	function load_class($class, $directory = 'libraries', $prefix = 'CI_')
@@ -86,6 +87,7 @@
 		return $obj;
 	}
 }
+*/
 
 // Clean up error messages
 // --------------------------------------------------------------------
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index b654bc5..07ea85b 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -474,6 +474,7 @@
       -  Added function :func:`is_cli()` to replace the ``CI_Input::is_cli_request()`` method.
       -  Added function :func:`function_usable()` to work around a bug in `Suhosin <http://www.hardened-php.net/suhosin/>`.
       -  Removed the third (`$php_error`) argument from function :func:`log_message()`.
+      -  Changed internal function ``load_class()`` to accept a constructor parameter instead of (previously unused) class name prefix.
 
    -  :doc:`Output Library <libraries/output>` changes include: