Index: wp-includes/category-template.php
===================================================================
--- wp-includes/category-template.php	(revision 6642)
+++ wp-includes/category-template.php	(working copy)
@@ -308,6 +308,12 @@
 }
 
 function wp_tag_cloud( $args = '' ) {
+	$tag_cloud = get_tag_cloud($args);
+	$tag_cloud = apply_filters( 'wp_tag_cloud', $tag_cloud, $args );
+	echo $tag_cloud;
+}
+
+function get_tag_cloud( $args = '' ) {
 	$defaults = array(
 		'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
 		'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',
@@ -325,12 +331,7 @@
 	if ( is_wp_error( $return ) )
 		return false;
 
-	$return = apply_filters( 'wp_tag_cloud', $return, $args );
-
-	if ( 'array' == $args['format'] )
-		return $return;
-
-	echo $return;
+	return $return;
 }
 
 // $tags = prefetched tag array ( get_tags() )

