Index: wp-includes/theme.php
===================================================================
--- wp-includes/theme.php	(revision 8753)
+++ wp-includes/theme.php	(working copy)
@@ -256,7 +256,7 @@
 			}
 		}
 
-		$template_dir = dirname($template_files[0]);
+		$template_dir = dirname($template_files[count($template_files) - 1]);
 		$stylesheet_dir = dirname($stylesheet_files[0]);
 
 		if ( empty($template_dir) )

