Index: wp-includes/comment-template.php
===================================================================
--- wp-includes/comment-template.php	(revision 12304)
+++ wp-includes/comment-template.php	(working copy)
@@ -1192,11 +1192,11 @@
 			case 'div':
 				break;
 			case 'ol':
-				echo "<ol class='children'>\n";
+				$output .= "<ol class='children'>\n";
 				break;
 			default:
 			case 'ul':
-				echo "<ul class='children'>\n";
+				$output .= "<ul class='children'>\n";
 				break;
 		}
 	}
@@ -1216,11 +1216,11 @@
 			case 'div':
 				break;
 			case 'ol':
-				echo "</ol>\n";
+				$output .= "</ol>\n";
 				break;
 			default:
 			case 'ul':
-				echo "</ul>\n";
+				$output .= "</ul>\n";
 				break;
 		}
 	}
@@ -1253,31 +1253,32 @@
 			$tag = 'li';
 			$add_below = 'div-comment';
 		}
-?>
-		<<?php echo $tag ?> <?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>">
-		<?php if ( 'ul' == $args['style'] ) : ?>
-		<div id="div-comment-<?php comment_ID() ?>" class="comment-body">
-		<?php endif; ?>
-		<div class="comment-author vcard">
-		<?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, $args['avatar_size'] ); ?>
-		<?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?>
-		</div>
-<?php if ($comment->comment_approved == '0') : ?>
-		<em><?php _e('Your comment is awaiting moderation.') ?></em>
-		<br />
-<?php endif; ?>
 
-		<div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)'),'&nbsp;&nbsp;','') ?></div>
+		$output .= 
+				  '<'. $tag .' '. comment_class(empty( $args['has_children'] ) ? '' : 'parent', null, null, false) .' id="comment-'. get_comment_ID() .'">' . "\n";
+		if ( 'ul' == $args['style'] ) : 
+			$output .= '<div id="div-comment-'. get_comment_ID() .'" class="comment-body">' . "\n";
+		endif;
+		$output .= '<div class="comment-author vcard">' . "\n";
+		if ($args['avatar_size'] != 0)
+			$output .= get_avatar( $comment, $args['avatar_size'] );
+		$output .= sprintf(__('<cite class="fn">%s</cite> <span class="says">says:</span>' . "\n"), get_comment_author_link());
+		$output .= '</div>' . "\n";
+		if ($comment->comment_approved == '0') : 
+			$output .= '<em>' . __('Your comment is awaiting moderation.') . '</em> . "\n"';
+			$output .= '<br /> . "\n"';
+		endif;
 
-		<?php comment_text() ?>
+		$output .= '<div class="comment-meta commentmetadata"><a href="' . htmlspecialchars( get_comment_link( $comment->comment_ID ) ) .'">' . sprintf(__('%1$s at %2$s'), get_comment_date(),  get_comment_time()) . '</a>' . edit_comment_link(__('(Edit)'),'&nbsp;&nbsp;','', false) . '</div>' . "\n";
 
-		<div class="reply">
-		<?php comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
-		</div>
-		<?php if ( 'ul' == $args['style'] ) : ?>
-		</div>
-		<?php endif; ?>
-<?php
+		$output .= apply_filters('comment_text', get_comment_text() ) . "\n";
+
+		$output .= '<div class="reply">' . "\n" .
+				   get_comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) . "\n" .
+				   '</div>' . "\n";
+		if ( 'ul' == $args['style'] ) :
+			$output .= '</div>' . "\n";
+		endif;
 	}
 
 	/**
@@ -1295,9 +1296,9 @@
 			return;
 		}
 		if ( 'div' == $args['style'] )
-			echo "</div>\n";
+			$output .= "</div>\n";
 		else
-			echo "</li>\n";
+			$output .= "</li>\n";
 	}
 
 }
@@ -1322,7 +1323,7 @@
 	$comment_depth = 1;
 
 	$defaults = array('walker' => null, 'max_depth' => '', 'style' => 'ul', 'callback' => null, 'end-callback' => null, 'type' => 'all',
-		'page' => '', 'per_page' => '', 'avatar_size' => 32, 'reverse_top_level' => null, 'reverse_children' => '');
+		'page' => '', 'per_page' => '', 'avatar_size' => 32, 'reverse_top_level' => null, 'reverse_children' => '', 'echo' => 1);
 
 	$r = wp_parse_args( $args, $defaults );
 
@@ -1390,10 +1391,15 @@
 	if ( empty($walker) )
 		$walker = new Walker_Comment;
 
-	$walker->paged_walk($_comments, $max_depth, $page, $per_page, $r);
+	$output = $walker->paged_walk($_comments, $max_depth, $page, $per_page, $r);
 	$wp_query->max_num_comment_pages = $walker->max_pages;
 
 	$in_comment_loop = false;
+
+	if ( $r['echo'] )
+		echo $output;
+	else
+		return $output;
 }
 
 ?>
Index: wp-includes/link-template.php
===================================================================
--- wp-includes/link-template.php	(revision 12304)
+++ wp-includes/link-template.php	(working copy)
@@ -765,7 +765,7 @@
  * @param string $after Optional. Display after edit link.
  * @return string|null HTML content, if $echo is set to false.
  */
-function edit_comment_link( $link = 'Edit This', $before = '', $after = '' ) {
+function edit_comment_link( $link = 'Edit This', $before = '', $after = '', $echo = true ) {
 	global $comment, $post;
 
 	if ( $post->post_type == 'page' ) {
@@ -777,7 +777,10 @@
 	}
 
 	$link = '<a class="comment-edit-link" href="' . get_edit_comment_link( $comment->comment_ID ) . '" title="' . __( 'Edit comment' ) . '">' . $link . '</a>';
-	echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after;
+	if ($echo)
+		echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after;
+	else
+		return $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after;
 }
 
 /**
