diff --git a/cake/libs/error.php b/cake/libs/error.php
index 684d6ad17..2202a8f19 100644
--- a/cake/libs/error.php
+++ b/cake/libs/error.php
@@ -36,9 +36,7 @@ App::import('Controller', 'App');
  * @subpackage	cake.cake.libs
  */
 class CakeErrorController extends AppController {
-
 	var $name = 'CakeError';
-
 	var $uses = array();
 
 	function __construct() {
@@ -49,7 +47,6 @@ class CakeErrorController extends AppController {
 		$this->Component->initialize($this);
 		$this->_set(array('cacheAction' => false, 'viewPath' => 'errors'));
 	}
-
 }
 /**
  * Short description for file.
@@ -67,7 +64,6 @@ class ErrorHandler extends Object {
  * @access public
  */
 	var $controller = null;
-
 /**
  * Class constructor.
  *
@@ -78,12 +74,11 @@ class ErrorHandler extends Object {
 		App::import('Core', 'Sanitize');
 
 		$this->controller =& new CakeErrorController();
-
 		$allow = array('.', '/', '_', ' ', '-', '~');
+
 		if (substr(PHP_OS, 0, 3) == "WIN") {
 			$allow = array_merge($allow, array('\\', ':'));
 		}
-
 		$messages = Sanitize::paranoid($messages, $allow);
 
 		if (!isset($messages[0])) {
@@ -284,10 +279,10 @@ class ErrorHandler extends Object {
  */
 	function missingHelperFile($params) {
 		extract($params, EXTR_OVERWRITE);
-		
+
 		$index = array_search($helper, $this->controller->helpers);
 		unset($this->controller->helpers[$index]);
-		
+
 		$this->controller->set(array(
 			'helperClass' => Inflector::camelize($helper) . "Helper",
 			'file' => $file,
@@ -303,10 +298,10 @@ class ErrorHandler extends Object {
  */
 	function missingHelperClass($params) {
 		extract($params, EXTR_OVERWRITE);
-		
+
 		$index = array_search($helper, $this->controller->helpers);
 		unset($this->controller->helpers[$index]);
-		
+
 		$this->controller->set(array(
 			'helperClass' => Inflector::camelize($helper) . "Helper",
 			'file' => $file,
@@ -374,5 +369,4 @@ class ErrorHandler extends Object {
 		echo $this->controller->output;
 	}
 }
-
 ?>
\ No newline at end of file
diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php
index f77334377..56518f375 100644
--- a/cake/libs/model/model.php
+++ b/cake/libs/model/model.php
@@ -1991,12 +1991,12 @@ class Model extends Overloadable {
 			$return = $idMap = array();
 			foreach ($results as $result) {
 				$result['children'] = array();
-				$id = $result[$this->alias]['id'];
+				$id = $result[$this->alias][$this->primaryKey];
 				$parentId = $result[$this->alias]['parent_id'];
 				if (isset($idMap[$id]['children'])) {
-					$idMap[$id] = am($result, $idMap[$id]);
+					$idMap[$id] = array_merge($result, (array)$idMap[$id]);
 				} else {
-					$idMap[$id] = am($result, array('children' => array()));
+					$idMap[$id] = array_merge($result, array('children' => array()));
 				}
 				if ($parentId) {
 					$idMap[$parentId]['children'][] =& $idMap[$id];
diff --git a/cake/tests/cases/dispatcher.test.php b/cake/tests/cases/dispatcher.test.php
index 34457aa9c..bac6fee97 100644
--- a/cake/tests/cases/dispatcher.test.php
+++ b/cake/tests/cases/dispatcher.test.php
@@ -562,17 +562,16 @@ class DispatcherTest extends UnitTestCase {
 		$Dispatcher =& new Dispatcher();
 		$uri = 'posts/home/?coffee=life&sleep=sissies';
 		$result = $Dispatcher->parseParams($uri);
-		$this->assertPattern('/posts/',$result['controller']);
-		$this->assertPattern('/home/',$result['action']);
+		$this->assertPattern('/posts/', $result['controller']);
+		$this->assertPattern('/home/', $result['action']);
 		$this->assertTrue(isset($result['url']['sleep']));
 		$this->assertTrue(isset($result['url']['coffee']));
 
-
 		$Dispatcher =& new Dispatcher();
 		$uri = '/?coffee=life&sleep=sissy';
 		$result = $Dispatcher->parseParams($uri);
-		$this->assertPattern('/pages/',$result['controller']);
-		$this->assertPattern('/display/',$result['action']);
+		$this->assertPattern('/pages/', $result['controller']);
+		$this->assertPattern('/display/', $result['action']);
 		$this->assertTrue(isset($result['url']['sleep']));
 		$this->assertTrue(isset($result['url']['coffee']));
 		$this->assertEqual($result['url']['coffee'], 'life');