diff -urp drake/drake.module drake_new/drake.module
--- drake/drake.module	2007-05-11 11:59:37.000000000 -0700
+++ drake_new/drake.module	2007-05-11 13:40:36.000000000 -0700
@@ -253,6 +253,11 @@ function drake_dispatcher($application =
 {
 	$settings = _drake_parseConfiguration($application);
 	
+	if ($settings['application']['default'] == 1)
+	{
+	    $application = null;
+	}
+	
 	$parameters = array();
 	
 	$parameters['cake_path'] = $settings['application']['path'];
@@ -266,9 +271,19 @@ function drake_dispatcher($application =
 	$parameters['drupal_url'] = url('drake' . (isset($application) ? '/' . $application : ''));	
 	$parameters['clean'] = (isset($_REQUEST['task']) && strcasecmp($_REQUEST['task'], 'clean') == 0 ? true : false);
 	
-	if (isset($_REQUEST['run']))
+	if (variable_get('clean_url') == 1)
+	{
+	    if (preg_match('!^' . url('drake') . (isset($application) ? '/' . $application : '') . '/?(.*)$!', $_SERVER['REQUEST_URI'], $reg))
+	    {
+	        $parameters['url'] = $reg[1];
+	    }
+	}
+	else
 	{
-		$parameters['url'] = $_REQUEST['run'];
+	    if (isset($_REQUEST['run']))
+	    {
+	        $parameters['url'] = $_REQUEST['run'];
+	    }
 	}
 	
 	// Startup
@@ -297,7 +312,7 @@ function drake_dispatcher($application =
 	$cakeDispatcher->setRestoreSession(false);
 	$cakeDispatcher->setCakePath($parameters['cake_path']);
 	$cakeDispatcher->setCakeUrlBase($parameters['cake_url']);
-	$cakeDispatcher->setComponent($parameters['drupal_url'] . (strpos($parameters['drupal_url'], '?') !== false ? '&' : '?') . 'run=$CAKE_ACTION');
+	$cakeDispatcher->setComponent($parameters['drupal_url'] . ((variable_get('clean_url') == 1) ? '' : (strpos($parameters['drupal_url'], '?') !== false ? '&' : '?') . 'run=') . '$CAKE_ACTION');
 	$cakeDispatcher->setCleanOutput((isset($parameters['clean']) ? $parameters['clean'] : false));
 	$cakeDispatcher->setCleanOutputParameter('task', 'clean');
 	$cakeDispatcher->setIgnoreParameters(array('q', 'task'));
@@ -520,7 +535,7 @@ function _drake_parseConfiguration($curr
 		}
 	}
 	
-	if (isset($currentApplicationId))
+	if (isset($currentApplicationId) && isset($applications[$currentApplicationId]))
 	{
 		$currentApplication = $currentApplicationId;
 	}
diff -urp drake/lib/cake_embedded_dispatcher.class.php drake_new/lib/cake_embedded_dispatcher.class.php
--- drake/lib/cake_embedded_dispatcher.class.php	2007-05-11 11:59:37.000000000 -0700
+++ drake_new/lib/cake_embedded_dispatcher.class.php	2007-05-11 13:29:24.000000000 -0700
@@ -613,16 +613,26 @@ class CakeEmbeddedDispatcher
 		
 		if ($useComponent)
 		{
-			$newUrl = str_replace('$CAKE_ACTION', urlencode($url), $this->component);
+		    if (variable_get('clean_url') == 1)
+		    {
+		        $delimiter = '/';
+		        $encoded_url = $url;
+		    }
+		    else
+		    {
+		        $delimiter = '&amp;';
+		        $encoded_url = urlencode($url);
+		    }
+			$newUrl = str_replace('$CAKE_ACTION', $encoded_url, $this->component);
 			
 			if (!empty($this->cakeUrlAddParameters))
 			{
-				$newUrl .= '&amp;' . $this->cakeUrlAddParameters;
+				$newUrl .= $delimiter . $this->cakeUrlAddParameters;
 			}
 			
 			if ($clean)
 			{
-				$newUrl .= '&amp;' . $this->cleanOutputParameter;
+				$newUrl .= $delimiter . $this->cleanOutputParameter;
 			}
 		}
 		else
diff -urp drake/lib/drake.class.php drake_new/lib/drake.class.php
--- drake/lib/drake.class.php	2007-05-11 11:59:37.000000000 -0700
+++ drake_new/lib/drake.class.php	2007-05-11 13:27:01.000000000 -0700
@@ -141,8 +141,15 @@ class Drake
 		
 		if (isset($action))
 		{
-			$url .= (strpos($url, '?') !== false ? '&' : '?');
-			$url .= 'run=' . urlencode($action);
+		    if (variable_get('clean_url') == 1)
+            {
+                $url .= '/' . $action;
+            }
+            else
+            {
+                $url .= (strpos($url, '?') !== false ? '&' : '?');
+                $url .= 'run=' . urlencode($action);
+            }
 		}
 		
 		return $url;
