Index: /trunk/wp-blog-header.php
===================================================================
--- /trunk/wp-blog-header.php	(revision 1971)
+++ /trunk/wp-blog-header.php	(revision 1972)
@@ -108,5 +108,5 @@
 }
 
-if (1 == $tb) {
+if (is_trackback()) {
     $doing_trackback = true;
 }
@@ -211,64 +211,50 @@
 		do_action('template_redirect', '');
 		if (is_feed()) {
-			$wp_did_template_redirect = true;
 			include(dirname(__FILE__) . '/wp-feed.php');
 			exit;
-		} else if ($tb == 1) {
-			$wp_did_template_redirect = true;
+		} else if (is_trackback()) {
 			include(dirname(__FILE__) . '/wp-trackback.php');
 			exit;
 		} else if (is_404() &&
 							 file_exists("$wp_template_dir/404.php")) {
-			$wp_did_template_redirect = true;
 			include("$wp_template_dir/404.php");
 			exit;
 		} else if (is_home() && 
 				file_exists("$wp_template_dir/index.php")) {
-			$wp_did_template_redirect = true;
 			include("$wp_template_dir/index.php");
 			exit;
 		} else if (is_single() &&
 							 file_exists("$wp_template_dir/single.php")) {
-			$wp_did_template_redirect = true;
 			include("$wp_template_dir/single.php");
 			exit;
 		} else if (is_page() && file_exists(get_page_template())) {
-			$wp_did_template_redirect = true;
 			include(get_page_template());
 			exit;
 		} else if (is_category() &&
 							 file_exists("$wp_template_dir/category.php")) {
-			$wp_did_template_redirect = true;
 			include("$wp_template_dir/category.php");
 			exit;
 		} else if (is_author() &&
 							 file_exists("$wp_template_dir/author.php")) {
-			$wp_did_template_redirect = true;
 			include("$wp_template_dir/author.php");
 			exit;
 		} else if (is_date() &&
 							 file_exists("$wp_template_dir/date.php")) {
-			$wp_did_date = true;
-			$wp_did_template_redirect = true;
 			include("$wp_template_dir/date.php");
 			exit;
 		} else if (is_archive() &&
 							 file_exists("$wp_template_dir/archive.php")) {
-			$wp_did_template_redirect = true;
 			include("$wp_template_dir/archive.php");
 			exit;
 		} else if (is_search() &&
 							 file_exists("$wp_template_dir/search.php")) {
-			$wp_did_template_redirect = true;
 			include("$wp_template_dir/search.php");
 			exit;
 		} else if (is_paged() &&
 							 file_exists("$wp_template_dir/paged.php")) {
-			$wp_did_template_redirect = true;
 			include("$wp_template_dir/paged.php");
 			exit;
 		} else if (file_exists("$wp_template_dir/index.php"))
 			{
-				$wp_did_template_redirect = true;
 				include("$wp_template_dir/index.php");
 				exit;
Index: /trunk/wp-includes/classes.php
===================================================================
--- /trunk/wp-includes/classes.php	(revision 1971)
+++ /trunk/wp-includes/classes.php	(revision 1972)
@@ -24,4 +24,5 @@
 	var $is_search = false;
 	var $is_feed = false;
+	var $is_trackback = false;
 	var $is_home = false;
 	var $is_404 = false;
@@ -40,4 +41,5 @@
 		$this->is_search = false;
 		$this->is_feed = false;
+		$this->is_trackback = false;
 		$this->is_home = false;
 		$this->is_404 = false;
@@ -62,105 +64,98 @@
 		if ('' != $qv['name']) {
 			$this->is_single = true;
-		}
-
-		if (($qv['p'] != '') && ($qv['p'] != 'all')) {
+		} else 	if (($qv['p'] != '') && ($qv['p'] != 'all')) {
 			$this->is_single = true;            
-		}
-
-		if ('' != $qv['static'] || '' != $qv['pagename'] || '' != $qv['page_id']) {
+		}	else if (('' != $qv['hour']) && ('' != $qv['minute']) &&('' != $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day'])) {
+			// If year, month, day, hour, minute, and second are set, a single 
+		  // post is being queried.        
+			$this->is_single = true;
+		} else if ('' != $qv['static'] || '' != $qv['pagename'] || '' != $qv['page_id']) {
 			$this->is_page = true;
 			$this->is_single = false;
-		}
-
-		if ( (int) $qv['second']) {
-			$this->is_time = true;
-			$this->is_date = true;
-		}
-
-		if ( (int) $qv['minute']) {
-			$this->is_time = true;
-			$this->is_date = true;
-		}
-
-		if ( (int) $qv['hour']) {
-			$this->is_time = true;
-			$this->is_date = true;
-		}
-
-		if ( (int) $qv['day']) {
-			if (! $this->is_date) {
-				$this->is_day = true;
+		} else if (!empty($qv['s'])) {
+			$this->is_search = true;
+		} else {
+			// Look for archive queries.  Dates, categories, authors.
+
+			if ( (int) $qv['second']) {
+				$this->is_time = true;
 				$this->is_date = true;
 			}
-		}
-
-		if ( (int)  $qv['monthnum']) {
-			if (! $this->is_date) {
-				$this->is_month = true;
+
+			if ( (int) $qv['minute']) {
+				$this->is_time = true;
 				$this->is_date = true;
 			}
-		}
-
-		if ( (int)  $qv['year']) {
-			if (! $this->is_date) {
-				$this->is_year = true;
+
+			if ( (int) $qv['hour']) {
+				$this->is_time = true;
 				$this->is_date = true;
 			}
-		}
-
-		if ( (int)  $qv['m']) {
-			$this->is_date = true;
-			if (strlen($qv['m']) > 9) {
-				$this->is_time = true;
-			} else if (strlen($qv['m']) > 7) {
-				$this->is_day = true;
-			} else if (strlen($qv['m']) > 5) {
-				$this->is_month = true;
-			} else {
-				$this->is_year = true;
-			}
-		}
-
-		if ('' != $qv['w']) {
-			$this->is_date = true;
-		}
-
-		// If year, month, day, hour, minute, and second are set, a single 
-		// post is being queried.        
-		if (('' != $qv['hour']) && ('' != $qv['minute']) &&('' != $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day'])) {
-			$this->is_single = true;
-		}
-
-		if (!empty($qv['s'])) {
-			$this->is_search = true;
-		}
-
-		if (empty($qv['cat']) || ($qv['cat'] == 'all') || ($qv['cat'] == '0')) {
-			$this->is_category = false;
-		} else {
-			if (stristr($qv['cat'],'-')) {
+
+			if ( (int) $qv['day']) {
+				if (! $this->is_date) {
+					$this->is_day = true;
+					$this->is_date = true;
+				}
+			}
+
+			if ( (int)  $qv['monthnum']) {
+				if (! $this->is_date) {
+					$this->is_month = true;
+					$this->is_date = true;
+				}
+			}
+
+			if ( (int)  $qv['year']) {
+				if (! $this->is_date) {
+					$this->is_year = true;
+					$this->is_date = true;
+				}
+			}
+
+			if ( (int)  $qv['m']) {
+				$this->is_date = true;
+				if (strlen($qv['m']) > 9) {
+					$this->is_time = true;
+				} else if (strlen($qv['m']) > 7) {
+					$this->is_day = true;
+				} else if (strlen($qv['m']) > 5) {
+					$this->is_month = true;
+				} else {
+					$this->is_year = true;
+				}
+			}
+
+			if ('' != $qv['w']) {
+				$this->is_date = true;
+			}
+
+			if (empty($qv['cat']) || ($qv['cat'] == 'all') || ($qv['cat'] == '0')) {
 				$this->is_category = false;
 			} else {
+				if (stristr($qv['cat'],'-')) {
+					$this->is_category = false;
+				} else {
+					$this->is_category = true;
+				}
+			}
+
+			if ('' != $qv['category_name']) {
 				$this->is_category = true;
 			}
-		}
-
-		if ('' != $qv['category_name']) {
-			$this->is_category = true;
-		}
             
-		// single, page, date, and search override category.
-		if ($this->is_single || $this->is_page || $this->is_date || $this->is_search) {
-			$this->is_category = false;                
-		}
-
-		if ((empty($qv['author'])) || ($qv['author'] == 'all') || ($qv['author'] == '0')) {
-			$this->is_author = false;
-		} else {
-			$this->is_author = true;
-		}
-
-		if ('' != $qv['author_name']) {
-			$this->is_author = true;
+			if ((empty($qv['author'])) || ($qv['author'] == 'all') || ($qv['author'] == '0')) {
+				$this->is_author = false;
+			} else {
+				$this->is_author = true;
+			}
+
+			if ('' != $qv['author_name']) {
+				$this->is_author = true;
+			}
+
+			if ( ($this->is_date || $this->is_author || $this->is_category)) {
+				$this->is_archive = true;
+			}
 		}
 
@@ -169,4 +164,8 @@
 		}
 
+		if ('' != $qv['tb']) {
+			$this->is_trackback = true;
+		}
+
 		if ('404' == $qv['error']) {
 			$this->is_404 = true;
@@ -177,10 +176,5 @@
 		}
 
-		if ( ($this->is_date || $this->is_author || $this->is_category)
-				 && (! ($this->is_single || $this->is_page)) ) {
-			$this->is_archive = true;
-		}
-
-		if ( ! ($this->is_archive || $this->is_single || $this->is_page || $this->is_search || $this->is_feed || $this->is_404)) {
+		if ( ! ($this->is_archive || $this->is_single || $this->is_page || $this->is_search || $this->is_feed || $this->is_trackback || $this->is_404)) {
 			$this->is_home = true;
 		}
@@ -900,5 +894,5 @@
 	}
 
-	function generate_rewrite_rules($permalink_structure = '', $page = true, $feed = true, $forcomments = false) {
+	function generate_rewrite_rules($permalink_structure, $page = true, $feed = true, $forcomments = false, $walk_dirs = true) {
 		$feedregex2 = '(feed|rdf|rss|rss2|atom)/?$';
 		$feedregex = 'feed/' . $feedregex2;
Index: /trunk/wp-includes/functions.php
===================================================================
--- /trunk/wp-includes/functions.php	(revision 1971)
+++ /trunk/wp-includes/functions.php	(revision 1972)
@@ -1196,4 +1196,10 @@
 }
 
+function is_trackback () {
+    global $wp_query;
+
+    return $wp_query->is_trackback;
+}
+
 function is_home () {
     global $wp_query;
