Index: wp-includes/functions.php
===================================================================
--- wp-includes/functions.php	(revision 3108)
+++ wp-includes/functions.php	(working copy)
@@ -2146,4 +2146,9 @@
 	return $file;
 }
 
-?>
+function get_num_queries() {
+	global $wpdb;
+	return $wpdb->num_queries;
+}
+
+?>
\ No newline at end of file
Index: wp-includes/comment-functions.php
===================================================================
--- wp-includes/comment-functions.php	(revision 3108)
+++ wp-includes/comment-functions.php	(working copy)
@@ -863,4 +863,9 @@
 	return true;
 }
 
+function get_approved_comments($post_id) {
+	global $wpdb;
+	return $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $post_id AND comment_approved = '1' ORDER BY comment_date");
+}
+
 ?>
Index: wp-content/themes/classic/footer.php
===================================================================
--- wp-content/themes/classic/footer.php	(revision 3108)
+++ wp-content/themes/classic/footer.php	(working copy)
@@ -3,7 +3,7 @@
 
 <?php get_sidebar(); ?>
 
-<p class="credit"><!--<?php echo $wpdb->num_queries; ?> queries. <?php timer_stop(1); ?> seconds. --> <cite><?php echo sprintf(__("Powered by <a href='http://wordpress.org/' title='%s'><strong>WordPress</strong></a>"), __("Powered by WordPress, state-of-the-art semantic personal publishing platform.")); ?></cite></p>
+<p class="credit"><!--<?php echo get_num_queries(); ?> queries. <?php timer_stop(1); ?> seconds. --> <cite><?php echo sprintf(__("Powered by <a href='http://wordpress.org/' title='%s'><strong>WordPress</strong></a>"), __("Powered by WordPress, state-of-the-art semantic personal publishing platform.")); ?></cite></p>
 
 </div>
 
Index: wp-content/themes/classic/comments-popup.php
===================================================================
--- wp-content/themes/classic/comments-popup.php	(revision 3108)
+++ wp-content/themes/classic/comments-popup.php	(working copy)
@@ -32,8 +32,8 @@
 $comment_author = (isset($_COOKIE['comment_author_' . COOKIEHASH])) ? trim($_COOKIE['comment_author_'. COOKIEHASH]) : '';
 $comment_author_email = (isset($_COOKIE['comment_author_email_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_email_'. COOKIEHASH]) : '';
 $comment_author_url = (isset($_COOKIE['comment_author_url_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_url_'. COOKIEHASH]) : '';
-$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved = '1' ORDER BY comment_date");
-$commentstatus = $wpdb->get_row("SELECT comment_status, post_password FROM $wpdb->posts WHERE ID = $id");
+$comments = get_approved_comments($id);
+$commentstatus = get_post($id);
 if (!empty($commentstatus->post_password) && $_COOKIE['wp-postpass_'. COOKIEHASH] != $commentstatus->post_password) {  // and it doesn't match the cookie
 	echo(get_the_password_form());
 } else { ?>
Index: wp-content/themes/default/footer.php
===================================================================
--- wp-content/themes/default/footer.php	(revision 3108)
+++ wp-content/themes/default/footer.php	(working copy)
@@ -6,7 +6,7 @@
 		<a href="http://wordpress.org/">WordPress</a>
 		<br /><a href="feed:<?php bloginfo('rss2_url'); ?>">Entries (RSS)</a>
 		and <a href="feed:<?php bloginfo('comments_rss2_url'); ?>">Comments (RSS)</a>.
-		<!-- <?php echo $wpdb->num_queries; ?> queries. <?php timer_stop(1); ?> seconds. -->
+		<!-- <?php echo get_num_queries(); ?> queries. <?php timer_stop(1); ?> seconds. -->
 	</p>
 </div>
 </div>
Index: wp-content/themes/default/comments-popup.php
===================================================================
--- wp-content/themes/default/comments-popup.php	(revision 3108)
+++ wp-content/themes/default/comments-popup.php	(working copy)
@@ -32,9 +32,9 @@
 $comment_author = (isset($_COOKIE['comment_author_' . COOKIEHASH])) ? trim($_COOKIE['comment_author_'. COOKIEHASH]) : '';
 $comment_author_email = (isset($_COOKIE['comment_author_email_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_email_'. COOKIEHASH]) : '';
 $comment_author_url = (isset($_COOKIE['comment_author_url_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_url_'. COOKIEHASH]) : '';
-$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved = '1' ORDER BY comment_date");
-$commentstatus = $wpdb->get_row("SELECT comment_status, post_password FROM $wpdb->posts WHERE ID = $id");
-if (!empty($commentstatus->post_password) && $_COOKIE['wp-postpass_'. COOKIEHASH] != $commentstatus->post_password) {  // and it doesn't match the cookie
+$comments = get_approved_comments($id);
+$post = get_post($id);
+if (!empty($post->post_password) && $_COOKIE['wp-postpass_'. COOKIEHASH] != $post->post_password) {  // and it doesn't match the cookie
 	echo(get_the_password_form());
 } else { ?>
 
@@ -52,7 +52,7 @@
 	<p>No comments yet.</p>
 <?php } ?>
 
-<?php if ('open' == $commentstatus->comment_status) { ?>
+<?php if ('open' == $post->comment_status) { ?>
 <h2>Leave a comment</h2>
 <p>Line and paragraph breaks automatic, e-mail address never displayed, <acronym title="Hypertext Markup Language">HTML</acronym> allowed: <code><?php echo allowed_tags(); ?></code></p>
 
