Index: /trunk/wp-blog-header.php
===================================================================
--- /trunk/wp-blog-header.php	(revision 1909)
+++ /trunk/wp-blog-header.php	(revision 1910)
@@ -208,4 +208,6 @@
 if ($pagenow == 'index.php') {
 	if (! isset($wp_did_template_redirect)) {
+		$wp_did_template_redirect = true;
+		do_action('template_redirect', '');
 		if (is_feed()) {
 			$wp_did_template_redirect = true;
Index: /trunk/wp-includes/classes.php
===================================================================
--- /trunk/wp-includes/classes.php	(revision 1909)
+++ /trunk/wp-includes/classes.php	(revision 1910)
@@ -705,7 +705,8 @@
 	var $date_structure;
 	var $front;
-	var $prefix = '';
+	var $root = '';
 	var $index = 'index.php';
 	var $matches = '';
+	var $rules;
 	var $rewritecode = 
 		array(
@@ -877,5 +878,11 @@
 	}
 
-	function generate_rewrite_rules($permalink_structure = '', $forcomments = false) {
+	function add_rewrite_tag($tag, $pattern, $query) {
+		$this->rewritecode[] = $tag;
+		$this->rewritereplace[] = $pattern;
+		$this->queryreplace[] = $query;
+	}
+
+	function generate_rewrite_rules($permalink_structure = '', $page = true, $feed = true, $forcomments = false) {
 		$feedregex2 = '(feed|rdf|rss|rss2|atom)/?$';
 		$feedregex = 'feed/' . $feedregex2;
@@ -933,6 +940,10 @@
 				$feedquery2 .= '&withcomments=1';
 			}
-				
-			$rewrite = array($feedmatch => $feedquery, $feedmatch2 => $feedquery2, $pagematch => $pagequery);
+
+			$rewrite = array();
+			if ($feed) 
+				$rewrite = array($feedmatch => $feedquery, $feedmatch2 => $feedquery2);
+			if ($page)
+				$rewrite = $rewrite + array($pagematch => $pagequery);
 
 			if ($num_toks) {
@@ -981,11 +992,11 @@
 		
 		// Root
-		$root_rewrite = $this->generate_rewrite_rules($this->prefix . '/');
+		$root_rewrite = $this->generate_rewrite_rules($this->root . '/');
 
 		// Comments
-		$comments_rewrite = $this->generate_rewrite_rules($this->prefix . 'comments', true);
+		$comments_rewrite = $this->generate_rewrite_rules($this->root . 'comments',true, true, true);
 
 		// Search
-		$search_structure = $this->prefix . "search/%search%";
+		$search_structure = $this->root . "search/%search%";
 		$search_rewrite = $this->generate_rewrite_rules($search_structure);
 
@@ -1001,12 +1012,13 @@
 
 		// Deprecated style static pages
-		$page_structure = $this->prefix . 'site/%pagename%';
+		$page_structure = $this->root . 'site/%pagename%';
 		$old_page_rewrite = $this->generate_rewrite_rules($page_structure);
 
 		// Put them together.
-		$this->rewrite = $page_rewrite + $root_rewrite + $comments_rewrite + $old_page_rewrite + $search_rewrite + $category_rewrite + $author_rewrite + $date_rewrite + $post_rewrite;
-
-		$this->rewrite = apply_filters('rewrite_rules_array', $this->rewrite);
-		return $this->rewrite;
+		$this->rules = $page_rewrite + $root_rewrite + $comments_rewrite + $old_page_rewrite + $search_rewrite + $category_rewrite + $author_rewrite + $date_rewrite + $post_rewrite;
+
+		do_action('generate_rewrite_rules', '');
+		$this->rules = apply_filters('rewrite_rules_array', $this->rules);
+		return $this->rules;
 	}
 
@@ -1030,5 +1042,4 @@
 		$this->matches = '';
 		$rewrite = $this->rewrite_rules();
-
 		$num_rules = count($rewrite);
 		$rules .= "RewriteCond %{REQUEST_FILENAME} -f [OR]\n" .
@@ -1062,7 +1073,7 @@
 		$this->permalink_structure = get_settings('permalink_structure');
 		$this->front = substr($this->permalink_structure, 0, strpos($this->permalink_structure, '%'));		
-		$this->prefix = '';
+		$this->root = '';
 		if ($this->using_index_permalinks()) {
-			$this->prefix = $this->index . '/';
+			$this->root = $this->index . '/';
 		}
 		$this->category_base = get_settings('category_base');
Index: /trunk/wp-includes/functions.php
===================================================================
--- /trunk/wp-includes/functions.php	(revision 1909)
+++ /trunk/wp-includes/functions.php	(revision 1910)
@@ -2057,3 +2057,12 @@
 	add_query_arg($key, '', $query);
 }
+
+function load_template($file) {
+	global $posts, $post, $wp_did_header, $wp_did_template_redirect, $wp_query,
+		$wp_rewrite, $wpdb;
+
+	extract($wp_query->query_vars);
+
+	include($file);
+}
 ?>
