diff --git a/config/paths.php b/config/paths.php
index 9fef1f253..6c022da94 100644
--- a/config/paths.php
+++ b/config/paths.php
@@ -177,4 +177,10 @@ define ('IMAGES_URL',          '/img/');
  */
 define ('CSS_URL',            '/css/');
 
+/**
+ * Web path to the js files directory.
+ */
+define ('JS_URL',            '/js/');
+
+
 ?>
diff --git a/libs/basics.php b/libs/basics.php
index 6e728895c..93d52c7e5 100644
--- a/libs/basics.php
+++ b/libs/basics.php
@@ -54,7 +54,7 @@ function loadModels ()
    require (APP.'app_model.php');
    foreach (listClasses(MODELS) as $model_fn) 
    {
-      require (MODELS.$model_fn);
+      require_once (MODELS.$model_fn);
    }
 }
 
@@ -72,12 +72,12 @@ function loadControllers ()
 
    foreach (listClasses(HELPERS) as $helper) 
    {
-      require (HELPERS.$helper.'.php');
+      require_once (HELPERS.$helper.'.php');
    }
 
    foreach (listClasses(CONTROLLERS) as $controller) 
    {
-      require (CONTROLLERS.$controller.'.php');
+      require_once (CONTROLLERS.$controller.'.php');
    }
 }
 
@@ -92,10 +92,10 @@ function loadController ($name)
    $controller_fn = CONTROLLERS.Inflector::underscore($name).'_controller.php';
    $helper_fn = HELPERS.Inflector::underscore($name).'_helper.php';
 
-   require(APP.'app_controller.php');
+   require_once(APP.'app_controller.php');
 
    if (file_exists($helper_fn))
-      require($helper_fn);
+      require_once($helper_fn);
 
    return file_exists($controller_fn)? require($controller_fn): false;
 }
@@ -128,7 +128,7 @@ function config ()
       }
       elseif (file_exists(CONFIGS.$arg.'.php')) 
       {
-         include (CONFIGS.$arg.'.php');
+         include_once (CONFIGS.$arg.'.php');
          if (count($args) == 1) return true;
       }
       else 
diff --git a/libs/controller.php b/libs/controller.php
index 7bd1524f5..fe658481a 100644
--- a/libs/controller.php
+++ b/libs/controller.php
@@ -772,9 +772,6 @@ class Controller extends Object
               }
          } // end loop through manytomany relations.
 	    }
-
-
-
       return $fieldNames;
 	}
 }
diff --git a/libs/dispatcher.php b/libs/dispatcher.php
index 4526ee87b..d3ddaa9fd 100644
--- a/libs/dispatcher.php
+++ b/libs/dispatcher.php
@@ -85,9 +85,9 @@ class Dispatcher extends Object
  * @param string $url	URL information to work on.
  * @return boolean		Success
  */
-   function dispatch($url)
+   function dispatch($url, $additional_params=array())
    {
-      $params = $this->parseParams($url);
+      $params     = array_merge($this->parseParams($url), $additional_params);
       $missingController = false;
       $missingAction     = false;
       $missingView       = false;
@@ -119,22 +119,18 @@ class Dispatcher extends Object
       {
          $controller = new $ctrlClass($this);
       }
-
-      if (empty($params['action']))
+      
+      $classMethods = get_class_methods($controller);
+      $classVars = get_object_vars($controller);
+      
+      if ((empty($params['action'])) && in_array('index', $classMethods))
       {
-         if (method_exists($controller, 'index'))
-         {
-            $params['action'] = 'index';
-         }
-         else
-         {
-            $missingAction = true;
-         }
+          $params['action'] = 'index';
       }
-
-      if (!method_exists($controller, $params['action']))
+      
+      if(!in_array($params['action'], $classMethods))
       {
-         $missingAction = true;
+          $missingAction = true;
       }
       
       $controller->base        = $this->base;
@@ -143,24 +139,22 @@ class Dispatcher extends Object
       $controller->action      = $params['action'];
       $controller->data        = empty($params['data'])? null: $params['data'];
       $controller->passed_args = empty($params['pass'])? null: $params['pass'];
-      
-      foreach (get_object_vars($controller) as $name => $value)
+      $controller->viewpath = Inflector::underscore($ctrlName);
+      $controller->autoLayout = !$params['bare'];
+
+      if((in_array('scaffold', array_keys($classVars))) && ($missingAction === true || !empty($params['action'])))
       {
-          if(($name === 'scaffold' && $missingAction === true) 
-              || ($name === 'scaffold' && !empty($params['action'])))
-          {
-              if (!method_exists($controller, $params['action']))
-              { 
-                  if(empty($params['action']))
-                  {
-                      $params['action'] = 'index';
-                  }
-                  $this->scaffoldView($url, $controller, $params);
-                  exit;
+          if(!in_array($params['action'], $classMethods))
+          { 
+              if(empty($params['action']))
+              {
+                  $params['action'] = 'index';
               }
+              $this->scaffoldView($url, $controller, $params);
+              exit;
           }
       }
-      
+
       $controller->constructClasses();
       
       if ($missingAction)
@@ -226,7 +220,8 @@ class Dispatcher extends Object
       {
          $params['form'][$name] = $data;
       }
-
+      
+      $params['bare'] = empty($params['ajax'])? (empty($params['bare'])? 0: 1): 1;
       return $params;
    }
 
@@ -273,19 +268,24 @@ class Dispatcher extends Object
       return preg_match('/^(.*)\/public\/index\.php$/', $script_name, $r)? $r[1]: false;
    }
 
+   
 /**
  * Displays an error page (e.g. 404 Not found).
  *
  * @param int $code 	Error code (e.g. 404)
  * @param string $name 	Name of the error message (e.g. Not found)
  * @param string $message
+ * @return unknown
  */
    function error ($code, $name, $message)
-   {
-      $controller = new Controller ($this);
-      $controller->base = $this->base;
-      $controller->error($code, $name, $message);
-   }
+	{
+        $controller = new Controller ($this);
+        $controller->base = $this->base;
+        $controller->autoLayout = false;
+        $controller->set(array('code'=>$code, 'name'=>$name, 'message'=>$message));
+		return $controller->render('layouts/error');
+	}
+
 
 /**
  * Convenience method to display a 404 page.
diff --git a/libs/router.php b/libs/router.php
index aeb2becee..e65be9c4b 100644
--- a/libs/router.php
+++ b/libs/router.php
@@ -140,7 +140,8 @@ class Router extends Object {
          array()
       );
 
-
+      $this->connect('/bare/:controller/:action/*', array('bare'=>'1'));
+      $this->connect('/ajax/:controller/:action/*', array('bare'=>'1'));
       $this->routes[] = $admin_route;
       $this->routes[] = $default_route;
       
diff --git a/libs/view.php b/libs/view.php
index 29e0beb5b..2e94b5f10 100644
--- a/libs/view.php
+++ b/libs/view.php
@@ -552,7 +552,12 @@ class View extends Object
 
       return $out;
    }
-
+   
+    function fetch ($url)
+    {
+        $dispatcher = new Dispatcher();
+        return $dispatcher->dispatch($url, array('bare'=>1));
+    }
 }
 
 ?>
\ No newline at end of file