Index: wp-includes/theme.php
===================================================================
--- wp-includes/theme.php	(revision 19199)
+++ wp-includes/theme.php	(working copy)
@@ -342,46 +342,13 @@
 			$template_directory = trim( $theme_root . '/' . $template );
 		}
 
-		$stylesheet_files = array();
-		$template_files = array();
+		// Loop through the stylesheet (current theme) directory and add all CSS files to an array
+		$stylesheet_files = _get_theme_files( "$theme_root/$stylesheet/", '|\.css$|' );
+		
+		// Loop through the stylesheet (current theme) and template (parent theme) directories and add all PHP files to a single array
+		$template_files = array_merge( _get_theme_files( "$theme_root/$stylesheet/" ), _get_theme_files( "$template_directory" ) ); 
 
-		$stylesheet_dir = @ dir("$theme_root/$stylesheet");
-		if ( $stylesheet_dir ) {
-			while ( ($file = $stylesheet_dir->read()) !== false ) {
-				if ( !preg_match('|^\.+$|', $file) ) {
-					if ( preg_match('|\.css$|', $file) )
-						$stylesheet_files[] = "$theme_root/$stylesheet/$file";
-					elseif ( preg_match('|\.php$|', $file) )
-						$template_files[] = "$theme_root/$stylesheet/$file";
-				}
-			}
-			@ $stylesheet_dir->close();
-		}
-
-		$template_dir = @ dir("$template_directory");
-		if ( $template_dir ) {
-			while ( ($file = $template_dir->read()) !== false ) {
-				if ( preg_match('|^\.+$|', $file) )
-					continue;
-				if ( preg_match('|\.php$|', $file) ) {
-					$template_files[] = "$template_directory/$file";
-				} elseif ( is_dir("$template_directory/$file") ) {
-					$template_subdir = @ dir("$template_directory/$file");
-					if ( !$template_subdir )
-						continue;
-					while ( ($subfile = $template_subdir->read()) !== false ) {
-						if ( preg_match('|^\.+$|', $subfile) )
-							continue;
-						if ( preg_match('|\.php$|', $subfile) )
-							$template_files[] = "$template_directory/$file/$subfile";
-					}
-					@ $template_subdir->close();
-				}
-			}
-			@ $template_dir->close();
-		}
-
-		//Make unique and remove duplicates when stylesheet and template are the same i.e. most themes
+		// Make unique and remove duplicates when stylesheet and template are the same (i.e. most themes)
 		$template_files = array_unique($template_files);
 		$stylesheet_files = array_unique($stylesheet_files);
 
@@ -465,6 +432,42 @@
 }
 
 /**
+ * Recursively loop through a theme's subdirectories and add PHP files to an array
+ *
+ * @since ...
+ *
+ * @param string $dir The current directory to loop through
+ * @param string $match The regular expression to match for file type(s)
+ * @param array $ignore A list of files/directories to ignore
+ * @return array Paths of all theme PHP files.
+ */
+function _get_theme_files( $dir, $match = '|\.php$|', $ignore = array( '.', '..', '.svn', '.git' ) ) {
+	
+	$the_files = array();
+	
+	$the_subdir = @ opendir("$dir");
+	while ( false !== ( $the_file = readdir( $the_subdir ) ) ) {
+		// Skip the ignored files
+		if ( !in_array( $the_file, $ignore ) ) {			
+			// If we're looking at a directory, loop back for a second pass, otherwise handle the file
+			if ( is_dir( "$dir/$the_file" ) ) {
+				$inner_files = _get_theme_files( "$dir/$the_file", $match );
+				if ( is_array($inner_files) ) $the_files = array_merge( $the_files, $inner_files ); 
+			} else {
+				// if it's a matching file type, add it to the list, otherwise skip it
+				if ( preg_match( $match, $the_file) ) 
+					$the_files[] = "$dir/$the_file"; 
+				else
+					continue;
+		    }
+		}
+	}
+	@ closedir($the_subdir);
+
+	return $the_files;
+}
+
+/**
  * Retrieve theme roots.
  *
  * @since 2.9.0
Index: wp-admin/includes/theme.php
===================================================================
--- wp-admin/includes/theme.php	(revision 19199)
+++ wp-admin/includes/theme.php	(working copy)
@@ -179,8 +179,8 @@
 			$basename = str_replace($base, '', $template);
 
 			// don't allow template files in subdirectories
-			if ( false !== strpos($basename, '/') )
-				continue;
+			// if ( false !== strpos($basename, '/') )
+			// 	continue;
 
 			if ( 'functions.php' == $basename )
 				continue;
