protected function loadLibrary($libraryName, $parameters = null, array $directory = null, $newInstance = false) 
	{
		// First get the directories where the library can be located
		$directories = (is_null($directory) ? $this->libraryPaths : $directory);

		// Now figure out the className and subdir
		$class = trim($libraryName, '/');
		if (($last_slash = strrpos($class, '/')) !== FALSE)
		{
			// Extract the path
			$subdir = substr($class, 0, ++$last_slash);

			// Get the filename from the path
			$class = substr($class, $last_slash);
		}
		else
		{
			$subdir = '';
		}

		$class = ucfirst($class);

		// Is the library a core library, then load a core library
		if (file_exists(Core::$coreDir . DS . 'Libraries'.DS.$subdir.$class.'.php'))
		{
			// Load base library
			return $this->loadCoreLibrary($class, $subdir, $parameters, $directories, $newInstance);
		}

		// Otherwise try and load an Application Library
		return $this->loadAppLibrary($class, $subdir, $parameters, $directories, $newInstance);
	}