Index: includes/common/functions.php
--- includes/common/functions.php
+++ includes/common/functions.php
@@ -1184,38 +1184,39 @@
  * @param int $parent_id Parent id
  * @param string $post_type Post type. Defaults to 'post'
  * @uses bbp_get_topic_post_type() To get the topic post type
- * @uses wp_cache_get() To check if there is a cache of the last child id
- * @uses wpdb::prepare() To prepare the query
- * @uses wpdb::get_var() To get the result of the query in a variable
- * @uses wp_cache_set() To set the cache for future use
+ * @uses WP_Query To get get the posts
  * @uses apply_filters() Calls 'bbp_get_public_child_last_id' with the child
  *                        id, parent id and post type
  * @return int The last active post_id
  */
 function bbp_get_public_child_last_id( $parent_id = 0, $post_type = 'post' ) {
-	global $wpdb;
 
 	// Bail if nothing passed
 	if ( empty( $parent_id ) )
 		return false;
 
 	// The ID of the cached query
-	$cache_id    = 'bbp_parent_' . $parent_id . '_type_' . $post_type . '_child_last_id';
 	$post_status = array( bbp_get_public_status_id() );
 
 	// Add closed status if topic post type
 	if ( $post_type == bbp_get_topic_post_type() )
 		$post_status[] = bbp_get_closed_status_id();
 
-	// Join post statuses together
-	$post_status = "'" . join( "', '", $post_status ) . "'";
-
 	// Check for cache and set if needed
-	$child_id = wp_cache_get( $cache_id, 'bbpress' );
-	if ( empty( $child_id ) ) {
-		$child_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( {$post_status} ) AND post_type = '%s' ORDER BY ID DESC LIMIT 1;", $parent_id, $post_type ) );
-		wp_cache_set( $cache_id, $child_id, 'bbpress' );
-	}
+	$query = new WP_Query( array(
+		'fields'      => 'ids',
+		'post_parent' => $parent_id,
+		'post_status' => $post_status,
+		'post_type'   => $post_type,
+		
+		// Maybe change these later
+		'posts_per_page'         => 1,
+		'update_post_term_cache' => false,
+		'update_post_meta_cache' => false,
+		'ignore_sticky_posts'    => true,
+	) );
+	$child_id = array_shift( $query->posts );
+	unset( $query );
 
 	// Filter and return
 	return apply_filters( 'bbp_get_public_child_last_id', (int) $child_id, (int) $parent_id, $post_type );
@@ -1227,38 +1228,39 @@
  * @param int $parent_id Parent id
  * @param string $post_type Post type. Defaults to 'post'
  * @uses bbp_get_topic_post_type() To get the topic post type
- * @uses wp_cache_get() To check if there is a cache of the children count
- * @uses wpdb::prepare() To prepare the query
- * @uses wpdb::get_var() To get the result of the query in a variable
- * @uses wp_cache_set() To set the cache for future use
+ * @uses WP_Query To get get the posts
  * @uses apply_filters() Calls 'bbp_get_public_child_count' with the child
  *                        count, parent id and post type
  * @return int The number of children
  */
 function bbp_get_public_child_count( $parent_id = 0, $post_type = 'post' ) {
-	global $wpdb;
 
 	// Bail if nothing passed
 	if ( empty( $parent_id ) )
 		return false;
 
 	// The ID of the cached query
-	$cache_id    = 'bbp_parent_' . $parent_id . '_type_' . $post_type . '_child_count';
 	$post_status = array( bbp_get_public_status_id() );
 
 	// Add closed status if topic post type
-	if ( $post_type == bbp_get_topic_post_type() )
+	if ( bbp_get_topic_post_type() == $post_type )
 		$post_status[] = bbp_get_closed_status_id();
 
-	// Join post statuses together
-	$post_status = "'" . join( "', '", $post_status ) . "'";
-
 	// Check for cache and set if needed
-	$child_count = wp_cache_get( $cache_id, 'bbpress' );
-	if ( empty( $child_count ) ) {
-		$child_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( {$post_status} ) AND post_type = '%s';", $parent_id, $post_type ) );
-		wp_cache_set( $cache_id, $child_count, 'bbpress' );
-	}
+	$query = new WP_Query( array(
+		'fields'      => 'ids',
+		'post_parent' => $parent_id,
+		'post_status' => $post_status,
+		'post_type'   => $post_type,
+		
+		// Maybe change these later
+		'posts_per_page'         => -1,
+		'update_post_term_cache' => false,
+		'update_post_meta_cache' => false,
+		'ignore_sticky_posts'    => true,
+	) );
+	$child_count = $query->post_count;
+	unset( $query );
 
 	// Filter and return
 	return apply_filters( 'bbp_get_public_child_count', (int) $child_count, (int) $parent_id, $post_type );
@@ -1270,38 +1272,39 @@
  * @param int $parent_id Parent id
  * @param string $post_type Post type. Defaults to 'post'
  * @uses bbp_get_topic_post_type() To get the topic post type
- * @uses wp_cache_get() To check if there is a cache of the children
- * @uses wpdb::prepare() To prepare the query
- * @uses wpdb::get_col() To get the result of the query in an array
- * @uses wp_cache_set() To set the cache for future use
+ * @uses WP_Query To get get the posts
  * @uses apply_filters() Calls 'bbp_get_public_child_ids' with the child ids,
  *                        parent id and post type
  * @return array The array of children
  */
 function bbp_get_public_child_ids( $parent_id = 0, $post_type = 'post' ) {
-	global $wpdb;
 
 	// Bail if nothing passed
 	if ( empty( $parent_id ) )
 		return false;
 
 	// The ID of the cached query
-	$cache_id    = 'bbp_parent_public_' . $parent_id . '_type_' . $post_type . '_child_ids';
 	$post_status = array( bbp_get_public_status_id() );
 
 	// Add closed status if topic post type
 	if ( $post_type == bbp_get_topic_post_type() )
 		$post_status[] = bbp_get_closed_status_id();
 
-	// Join post statuses together
-	$post_status = "'" . join( "', '", $post_status ) . "'";
-
 	// Check for cache and set if needed
-	$child_ids = wp_cache_get( $cache_id, 'bbpress' );
-	if ( empty( $child_ids ) ) {
-		$child_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( {$post_status} ) AND post_type = '%s' ORDER BY ID DESC;", $parent_id, $post_type ) );
-		wp_cache_set( $cache_id, $child_ids, 'bbpress' );
-	}
+	$query = new WP_Query( array(
+		'fields'      => 'ids',
+		'post_parent' => $parent_id,
+		'post_status' => $post_status,
+		'post_type'   => $post_type,
+		
+		// Maybe change these later
+		'posts_per_page'         => -1,
+		'update_post_term_cache' => false,
+		'update_post_meta_cache' => false,
+		'ignore_sticky_posts'    => true,
+	) );
+	$child_ids = !empty( $query->posts ) ? $query->posts : array();
+	unset( $query );
 
 	// Filter and return
 	return apply_filters( 'bbp_get_public_child_ids', $child_ids, (int) $parent_id, $post_type );
@@ -1312,23 +1315,18 @@
  * @param int $parent_id Parent id
  * @param string $post_type Post type. Defaults to 'post'
  * @uses bbp_get_topic_post_type() To get the topic post type
- * @uses wp_cache_get() To check if there is a cache of the children
- * @uses wpdb::prepare() To prepare the query
- * @uses wpdb::get_col() To get the result of the query in an array
- * @uses wp_cache_set() To set the cache for future use
+ * @uses WP_Query To get get the posts
  * @uses apply_filters() Calls 'bbp_get_public_child_ids' with the child ids,
  *                        parent id and post type
  * @return array The array of children
  */
 function bbp_get_all_child_ids( $parent_id = 0, $post_type = 'post' ) {
-	global $wpdb;
 
 	// Bail if nothing passed
 	if ( empty( $parent_id ) )
 		return false;
 
 	// The ID of the cached query
-	$cache_id    = 'bbp_parent_all_' . $parent_id . '_type_' . $post_type . '_child_ids';
 	$post_status = array( bbp_get_public_status_id() );
 
 	// Extra post statuses based on post type
@@ -1354,15 +1352,21 @@
 			break;
 	}
 
-	// Join post statuses together
-	$post_status = "'" . join( "', '", $post_status ) . "'";
-
 	// Check for cache and set if needed
-	$child_ids = wp_cache_get( $cache_id, 'bbpress' );
-	if ( empty( $child_ids ) ) {
-		$child_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( {$post_status} ) AND post_type = '%s' ORDER BY ID DESC;", $parent_id, $post_type ) );
-		wp_cache_set( $cache_id, $child_ids, 'bbpress' );
-	}
+	$query = new WP_Query( array(
+		'fields'      => 'ids',
+		'post_parent' => $parent_id,
+		'post_status' => 'any',
+		'post_type'   => $post_type,
+		
+		// Maybe change these later
+		'posts_per_page'         => -1,
+		'update_post_term_cache' => false,
+		'update_post_meta_cache' => false,
+		'ignore_sticky_posts'    => true,
+	) );
+	$child_ids = !empty( $query->posts ) ? $query->posts : array();
+	unset( $query );
 
 	// Filter and return
 	return apply_filters( 'bbp_get_all_child_ids', $child_ids, (int) $parent_id, $post_type );
Index: includes/core/cache.php
--- includes/core/cache.php
+++ includes/core/cache.php
@@ -145,22 +145,6 @@
 
 	do_action( 'bbp_clean_post_cache', $_post->ID, $_post );
 
-	// Child query types to clean
-	$post_types = array(
-		bbp_get_topic_post_type(),
-		bbp_get_forum_post_type(),
-		bbp_get_reply_post_type()
-	);
-
-	// Loop through query types and clean caches
-	foreach ( $post_types as $post_type ) {
-		wp_cache_delete( 'bbp_get_forum_'     . $_post->ID . '_reply_id',                              'bbpress' );
-		wp_cache_delete( 'bbp_parent_'        . $_post->ID . '_type_' . $post_type . '_child_last_id', 'bbpress' );
-		wp_cache_delete( 'bbp_parent_'        . $_post->ID . '_type_' . $post_type . '_child_count',   'bbpress' );
-		wp_cache_delete( 'bbp_parent_public_' . $_post->ID . '_type_' . $post_type . '_child_ids',     'bbpress' );
-		wp_cache_delete( 'bbp_parent_all_'    . $_post->ID . '_type_' . $post_type . '_child_ids',     'bbpress' );
-	}
-
 	// Invalidate parent caches
 	if ( ! empty( $_post->post_parent ) ) {
 		bbp_clean_post_cache( $_post->post_parent );
Index: includes/forums/functions.php
--- includes/forums/functions.php
+++ includes/forums/functions.php
@@ -1368,7 +1368,6 @@
  * @return int Topic hidden topic count
  */
 function bbp_update_forum_topic_count_hidden( $forum_id = 0, $topic_count = 0 ) {
-	global $wpdb;
 
 	// If topic_id was passed as $forum_id, then get its forum
 	if ( bbp_is_topic( $forum_id ) ) {
@@ -1384,9 +1383,23 @@
 	if ( !empty( $forum_id ) ) {
 
 		// Get topics of forum
-		if ( empty( $topic_count ) )
-			$topic_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( '" . join( '\',\'', array( bbp_get_trash_status_id(), bbp_get_spam_status_id() ) ) . "') AND post_type = '%s';", $forum_id, bbp_get_topic_post_type() ) );
+		if ( empty( $topic_count ) ) {
+			$query = new WP_Query( array(
+				'fields'      => 'ids',
+				'post_parent' => $forum_id,
+				'post_status' => array( bbp_get_trash_status_id(), bbp_get_spam_status_id() ),
+				'post_type'   => bbp_get_topic_post_type(),
 
+				// Maybe change these later
+				'posts_per_page'         => -1,
+				'update_post_term_cache' => false,
+				'update_post_meta_cache' => false,
+				'ignore_sticky_posts'    => true,		
+			) );
+			$topic_count = $query->post_count;
+			unset( $query );
+		}
+
 		// Update the count
 		update_post_meta( $forum_id, '_bbp_topic_count_hidden', (int) $topic_count );
 	}
@@ -1416,8 +1429,6 @@
  * @return int Forum reply count
  */
 function bbp_update_forum_reply_count( $forum_id = 0 ) {
-	global $wpdb;
-
 	$forum_id = bbp_get_forum_id( $forum_id );
 	$children_reply_count = 0;
 
@@ -1431,10 +1442,24 @@
 
 	// Don't count replies if the forum is a category
 	$topic_ids = bbp_forum_query_topic_ids( $forum_id );
-	if ( !empty( $topic_ids ) )
-		$reply_count = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent IN ( " . join( ',', $topic_ids ) . " ) AND post_status = '%s' AND post_type = '%s';", bbp_get_public_status_id(), bbp_get_reply_post_type() ) );
-	else
+	if ( !empty( $topic_ids ) ) {
+		$query = new WP_Query( array(
+			'fields'          => 'ids',
+			'post_parent__in' => $topic_ids,
+			'post_status'     => bbp_get_public_status_id(),
+			'post_type'       => bbp_get_reply_post_type(),
+
+			// Maybe change these later
+			'posts_per_page'         => -1,
+			'update_post_term_cache' => false,
+			'update_post_meta_cache' => false,
+			'ignore_sticky_posts'    => true,		
+		) );
+		$reply_count = ! empty( $query->posts ) ? count( $query->posts ) : 0;
+		unset( $query );
+	} else {
 		$reply_count = 0;
+	}
 
 	// Calculate total replies in this forum
 	$total_replies = (int) $reply_count + $children_reply_count;
@@ -1749,61 +1774,47 @@
  */
 function bbp_forum_query_subforum_ids( $forum_id ) {
 	$subforum_ids = bbp_get_public_child_ids( $forum_id, bbp_get_forum_post_type() );
-	//usort( $subforum_ids, '_bbp_forum_query_usort_subforum_ids' );
 
 	return apply_filters( 'bbp_get_forum_subforum_ids', $subforum_ids, $forum_id );
 }
 
 /**
- * Callback to sort forum ID's based on last active time
- *
- * @since bbPress (r3789)
- * @param int $a First forum ID to compare
- * @param int $b Second forum ID to compare
- * @return Position change based on sort
- */
-function _bbp_forum_query_usort_subforum_ids( $a = 0, $b = 0 ) {
-	$ta = get_post_meta( $a, '_bbp_last_active_time', true );
-	$tb = get_post_meta( $b, '_bbp_last_active_time', true );
-	return ( $ta < $tb ) ? -1 : 1;
-}
-
-/**
  * Returns the forum's last reply id
  *
  * @since bbPress (r2908)
  *
  * @param int $forum_id Forum id
  * @param int $topic_ids Optional. Topic ids
- * @uses wp_cache_get() To check for cache and retrieve it
  * @uses bbp_forum_query_topic_ids() To get the forum's topic ids
- * @uses wpdb::prepare() To prepare the query
- * @uses wpdb::get_var() To execute the query and get the var back
  * @uses bbp_get_reply_post_type() To get the reply post type
- * @uses wp_cache_set() To set the cache for future use
  * @uses apply_filters() Calls 'bbp_forum_query_last_reply_id' with the reply id
  *                        and forum id
  */
-function bbp_forum_query_last_reply_id( $forum_id, $topic_ids = 0 ) {
-	global $wpdb;
+function bbp_forum_query_last_reply_id( $forum_id = 0, $topic_ids = 0 ) {
 
-	$cache_id = 'bbp_get_forum_' . $forum_id . '_reply_id';
-	$reply_id = (int) wp_cache_get( $cache_id, 'bbpress' );
+	// Validate forum
+	$forum_id = bbp_get_forum_id( $forum_id );
 
-	if ( empty( $reply_id ) ) {
+	// Get topic ID's if none were passed
+	if ( empty( $topic_ids ) )
+		$topic_ids = bbp_forum_query_topic_ids( $forum_id );
 
-		if ( empty( $topic_ids ) ) {
-			$topic_ids = bbp_forum_query_topic_ids( $forum_id );
-		}
+	// Check for cache and set if needed
+	$query = new WP_Query( array(
+		'fields'          => 'ids',
+		'post_parent__in' => $topic_ids,
+		'post_status'     => bbp_get_public_status_id(),
+		'post_type'       => bbp_get_reply_post_type(),
+		
+		// Maybe change these later
+		'posts_per_page'         => 1,
+		'update_post_term_cache' => false,
+		'update_post_meta_cache' => false,
+		'ignore_sticky_posts'    => true,
+	) );
+	$reply_id = array_shift( $query->posts );
+	unset( $query );
 
-		if ( !empty( $topic_ids ) ) {
-			$reply_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent IN ( " . join( ',', $topic_ids ) . " ) AND post_status = '%s' AND post_type = '%s' ORDER BY ID DESC LIMIT 1;", bbp_get_public_status_id(), bbp_get_reply_post_type() ) );
-			wp_cache_set( $cache_id, $reply_id, 'bbpress' ); // May be (int) 0
-		} else {
-			wp_cache_set( $cache_id, '0', 'bbpress' );
-		}
-	}
-
 	return (int) apply_filters( 'bbp_get_forum_last_reply_id', (int) $reply_id, $forum_id );
 }
 
Index: includes/replies/template-tags.php
--- includes/replies/template-tags.php
+++ includes/replies/template-tags.php
@@ -85,7 +85,7 @@
 		'post_status'    => $default_post_status,       // Of this status
 		'posts_per_page' => bbp_get_replies_per_page(), // This many
 		'paged'          => bbp_get_paged(),            // On this page
-		'orderby'        => 'date',                     // Sorted by date
+		'orderby'        => 'ID',                       // Sorted by ID
 		'order'          => 'ASC',                      // Oldest to newest
 		's'              => $default_reply_search,      // Maybe search
 	);
Index: includes/topics/functions.php
--- includes/topics/functions.php
+++ includes/topics/functions.php
@@ -2241,10 +2241,11 @@
 function bbp_update_topic_forum_id( $topic_id = 0, $forum_id = 0 ) {
 
 	// If it's a reply, then get the parent (topic id)
-	if ( bbp_is_reply( $topic_id ) )
+	if ( bbp_is_reply( $topic_id ) ) {
 		$topic_id = bbp_get_reply_topic_id( $topic_id );
-	else
+	} else {
 		$topic_id = bbp_get_topic_id( $topic_id );
+	}
 
 	if ( empty( $forum_id ) )
 		$forum_id = get_post_field( 'post_parent', $topic_id );
@@ -2293,10 +2294,11 @@
 function bbp_update_topic_reply_count( $topic_id = 0, $reply_count = 0 ) {
 
 	// If it's a reply, then get the parent (topic id)
-	if ( bbp_is_reply( $topic_id ) )
+	if ( bbp_is_reply( $topic_id ) ) {
 		$topic_id = bbp_get_reply_topic_id( $topic_id );
-	else
+	} else {
 		$topic_id = bbp_get_topic_id( $topic_id );
+	}
 
 	// Get replies of topic if not passed
 	if ( empty( $reply_count ) )
@@ -2329,10 +2331,11 @@
 	global $wpdb;
 
 	// If it's a reply, then get the parent (topic id)
-	if ( bbp_is_reply( $topic_id ) )
+	if ( bbp_is_reply( $topic_id ) ) {
 		$topic_id = bbp_get_reply_topic_id( $topic_id );
-	else
+	} else {
 		$topic_id = bbp_get_topic_id( $topic_id );
+	}
 
 	// Get replies of topic
 	if ( empty( $reply_count ) )
@@ -2364,10 +2367,11 @@
 function bbp_update_topic_last_active_id( $topic_id = 0, $active_id = 0 ) {
 
 	// If it's a reply, then get the parent (topic id)
-	if ( bbp_is_reply( $topic_id ) )
+	if ( bbp_is_reply( $topic_id ) ) {
 		$topic_id = bbp_get_reply_topic_id( $topic_id );
-	else
+	} else {
 		$topic_id = bbp_get_topic_id( $topic_id );
+	}
 
 	if ( empty( $active_id ) )
 		$active_id = bbp_get_public_child_last_id( $topic_id, bbp_get_reply_post_type() );
@@ -2399,18 +2403,21 @@
 function bbp_update_topic_last_active_time( $topic_id = 0, $new_time = '' ) {
 
 	// If it's a reply, then get the parent (topic id)
-	if ( bbp_is_reply( $topic_id ) )
+	if ( bbp_is_reply( $topic_id ) ) {
 		$topic_id = bbp_get_reply_topic_id( $topic_id );
-	else
+	} else {
 		$topic_id = bbp_get_topic_id( $topic_id );
+	}
 
 	// Check time and use current if empty
-	if ( empty( $new_time ) )
+	if ( empty( $new_time ) ) {
 		$new_time = get_post_field( 'post_date', bbp_get_public_child_last_id( $topic_id, bbp_get_reply_post_type() ) );
+	}
 
 	// Update only if published
-	if ( !empty( $new_time ) )
+	if ( !empty( $new_time ) ) {
 		update_post_meta( $topic_id, '_bbp_last_active_time', $new_time );
+	}
 
 	return apply_filters( 'bbp_update_topic_last_active_time', $new_time, $topic_id );
 }
Index: includes/users/functions.php
--- includes/users/functions.php
+++ includes/users/functions.php
@@ -1037,9 +1037,7 @@
  * Get the total number of users on the forums
  *
  * @since bbPress (r2769)
- * @uses wp_cache_get() Check if query is in cache
- * @uses get_users() To execute our query and get the var back
- * @uses wp_cache_set() Set the query in the cache
+ * @uses count_users() To execute our query and get the var back
  * @uses apply_filters() Calls 'bbp_get_total_users' with number of users
  * @return int Total number of users
  */
