Index: bp-friends.php
===================================================================
--- bp-friends.php	(revision 3694)
+++ bp-friends.php	(working copy)
@@ -556,7 +556,7 @@
 	if ( !$user_ids )
 		return false;
 
-	for ( $i = 0; $i < count($user_ids); $i++ ) {
+	for ( $i = 0, $j = count( $user_ids ); $i < $j; $i++ ) {
 		$users[] = new BP_Core_User($user_ids[$i]);
 	}
 
Index: bp-themes/bp-default/_inc/ajax.php
===================================================================
--- bp-themes/bp-default/_inc/ajax.php	(revision 3694)
+++ bp-themes/bp-default/_inc/ajax.php	(working copy)
@@ -514,7 +514,7 @@
 	} else {
 		$thread_ids = explode( ',', $_POST['thread_ids'] );
 
-		for ( $i = 0; $i < count($thread_ids); $i++ ) {
+		for ( $i = 0, $j = count( $thread_ids ); $i < $j; $i++ ) {
 			BP_Messages_Thread::mark_as_unread($thread_ids[$i]);
 		}
 	}
@@ -530,7 +530,7 @@
 	} else {
 		$thread_ids = explode( ',', $_POST['thread_ids'] );
 
-		for ( $i = 0; $i < count($thread_ids); $i++ ) {
+		for ( $i = 0, $j = count( $thread_ids ); $i < $j; $i++ ) {
 			BP_Messages_Thread::mark_as_read($thread_ids[$i]);
 		}
 	}
@@ -546,7 +546,7 @@
 	} else {
 		$thread_ids = explode( ',', $_POST['thread_ids'] );
 
-		for ( $i = 0; $i < count($thread_ids); $i++ )
+		for ( $i = 0, $j = count( $thread_ids ); $i < $j; $i++ )
 			BP_Messages_Thread::delete($thread_ids[$i]);
 
 		_e('Messages deleted.', 'buddypress');
Index: bp-core/bp-core-notifications.php
===================================================================
--- bp-core/bp-core-notifications.php	(revision 3694)
+++ bp-core/bp-core-notifications.php	(working copy)
@@ -39,8 +39,8 @@
 
 	$notifications = BP_Core_Notification::get_all_for_user( $user_id );
 
-	/* Group notifications by component and component_action and provide totals */
-	for ( $i = 0; $i < count($notifications); $i++ ) {
+	// Group notifications by component and component_action and provide totals
+	for ( $i = 0, $j = count( $notifications ); $i < $j; $i++ ) {
 		$notification = $notifications[$i];
 		$grouped_notifications[$notification->component_name][$notification->component_action][] = $notification;
 	}
@@ -48,7 +48,7 @@
 	if ( empty( $grouped_notifications ) )
 		return false;
 
-	/* Calculated a renderable outcome for each notification type */
+	// Calculated a renderable outcome for each notification type
 	foreach ( (array)$grouped_notifications as $component_name => $action_arrays ) {
 		if ( !$action_arrays )
 			continue;
Index: bp-core/bp-core-adminbar.php
===================================================================
--- bp-core/bp-core-adminbar.php	(revision 3694)
+++ bp-core/bp-core-adminbar.php	(working copy)
@@ -198,7 +198,7 @@
 
 	if ( $notifications ) {
 		$counter = 0;
-		for ( $i = 0; $i < count($notifications); $i++ ) {
+		for ( $i = 0, $j = count( $notifications ); $i < $j; $i++ ) {
 			$alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; ?>
 
 			<li<?php echo $alt ?>><?php echo $notifications[$i] ?></li>
Index: bp-core/bp-core-classes.php
===================================================================
--- bp-core/bp-core-classes.php	(revision 3694)
+++ bp-core/bp-core-classes.php	(working copy)
@@ -346,14 +346,14 @@
 		if ( empty( $user_ids ) )
 			return $paged_users;
 
-		/* Fetch the user's full name */
+		// Fetch the user's full name
 		if ( bp_is_active( 'xprofile' ) && 'alphabetical' != $type ) {
-			/* Ensure xprofile globals are set */
+			// Ensure xprofile globals are set
 			if ( !defined( 'BP_XPROFILE_FULLNAME_FIELD_NAME' ) )
 				xprofile_setup_globals();
 
 			$names = $wpdb->get_results( $wpdb->prepare( "SELECT pd.user_id as id, pd.value as fullname FROM {$bp->profile->table_name_fields} pf, {$bp->profile->table_name_data} pd WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} )", BP_XPROFILE_FULLNAME_FIELD_NAME ) );
-			for ( $i = 0; $i < count( $paged_users ); $i++ ) {
+			for ( $i = 0, $j = count( $paged_users ); $i < $j; $i++ ) {
 				foreach ( (array)$names as $name ) {
 					if ( $name->id == $paged_users[$i]->id )
 						$paged_users[$i]->fullname = $name->fullname;
@@ -361,10 +361,10 @@
 			}
 		}
 
-		/* Fetch the user's total friend count */
+		// Fetch the user's total friend count/
 		if ( 'popular' != $type ) {
 			$friend_count = $wpdb->get_results( "SELECT user_id as id, meta_value as total_friend_count FROM " . CUSTOM_USER_META_TABLE . " WHERE meta_key = 'total_friend_count' AND user_id IN ( {$user_ids} )" );
-			for ( $i = 0; $i < count( $paged_users ); $i++ ) {
+			for ( $i = 0, $j = count( $paged_users ); $i < $j; $i++ ) {
 				foreach ( (array)$friend_count as $count ) {
 					if ( $count->id == $paged_users[$i]->id )
 						$paged_users[$i]->total_friend_count = (int)$count->total_friend_count;
@@ -372,10 +372,10 @@
 			}
 		}
 
-		/* Fetch whether or not the user is a friend */
+		// Fetch whether or not the user is a friend
 		if ( bp_is_active( 'friends' ) ) {
 			$friend_status = $wpdb->get_results( $wpdb->prepare( "SELECT initiator_user_id, friend_user_id, is_confirmed FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d AND friend_user_id IN ( {$user_ids} ) ) OR (initiator_user_id IN ( {$user_ids} ) AND friend_user_id = %d )", $bp->loggedin_user->id, $bp->loggedin_user->id ) );
-			for ( $i = 0; $i < count( $paged_users ); $i++ ) {
+			for ( $i = 0, $j = count( $paged_users ); $i < $j; $i++ ) {
 				foreach ( (array)$friend_status as $status ) {
 					if ( $status->initiator_user_id == $paged_users[$i]->id || $status->friend_user_id == $paged_users[$i]->id )
 						$paged_users[$i]->is_friend = $status->is_confirmed;
@@ -385,7 +385,7 @@
 
 		if ( 'active' != $type ) {
 			$user_activity = $wpdb->get_results( "SELECT user_id as id, meta_value as last_activity FROM " . CUSTOM_USER_META_TABLE . " WHERE meta_key = 'last_activity' AND user_id IN ( {$user_ids} )" );
-			for ( $i = 0; $i < count( $paged_users ); $i++ ) {
+			for ( $i = 0, $j = count( $paged_users ); $i < $j; $i++ ) {
 				foreach ( (array)$user_activity as $activity ) {
 					if ( $activity->id == $paged_users[$i]->id )
 						$paged_users[$i]->last_activity = $activity->last_activity;
@@ -393,10 +393,10 @@
 			}
 		}
 
-		/* Fetch the user's last_activity */
+		// Fetch the user's last_activity
 		if ( 'active' != $type ) {
 			$user_activity = $wpdb->get_results( "SELECT user_id as id, meta_value as last_activity FROM " . CUSTOM_USER_META_TABLE . " WHERE meta_key = 'last_activity' AND user_id IN ( {$user_ids} )" );
-			for ( $i = 0; $i < count( $paged_users ); $i++ ) {
+			for ( $i = 0, $j = count( $paged_users ); $i < $j; $i++ ) {
 				foreach ( (array)$user_activity as $activity ) {
 					if ( $activity->id == $paged_users[$i]->id )
 						$paged_users[$i]->last_activity = $activity->last_activity;
@@ -404,9 +404,9 @@
 			}
 		}
 
-		/* Fetch the user's latest update */
+		// Fetch the user's latest update
 		$user_update = $wpdb->get_results( "SELECT user_id as id, meta_value as latest_update FROM " . CUSTOM_USER_META_TABLE . " WHERE meta_key = 'bp_latest_update' AND user_id IN ( {$user_ids} )" );
-		for ( $i = 0; $i < count( $paged_users ); $i++ ) {
+		for ( $i = 0, $j = count( $paged_users ); $i < $j; $i++ ) {
 			foreach ( (array)$user_update as $update ) {
 				if ( $update->id == $paged_users[$i]->id )
 					$paged_users[$i]->latest_update = $update->latest_update;
Index: bp-xprofile/bp-xprofile-templatetags.php
===================================================================
--- bp-xprofile/bp-xprofile-templatetags.php	(revision 3694)
+++ bp-xprofile/bp-xprofile-templatetags.php	(working copy)
@@ -98,7 +98,7 @@
 	function has_fields() {
 		$has_data = false;
 
-		for ( $i = 0; $i < count( $this->group->fields ); $i++ ) {
+		for ( $i = 0, $j = count( $this->group->fields ); $i < $j; $i++ ) {
 			$field = &$this->group->fields[$i];
 
 			if ( !empty( $field->data ) && $field->data->value != null ) {
@@ -415,7 +415,7 @@
 				if ( 'multiselectbox' != $field->type )
 					$html .= '<option value="">--------</option>';
 
-				for ( $k = 0; $k < count($options); $k++ ) {
+				for ( $k = 0, $l = count( $options ); $k < $l; $k++ ) {
 					$original_option_values = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid( $options[$k]->parent_id ) );
 					$option_values = (array) $original_option_values;
 
@@ -446,7 +446,7 @@
 			case 'radio':
 				$html .= '<div id="field_' . $field->id . '">';
 
-				for ( $k = 0; $k < count($options); $k++ ) {
+				for ( $k = 0, $l = count( $options ); $k < $l; $k++ ) {
 					$option_value = BP_XProfile_ProfileData::get_value_byid($options[$k]->parent_id);
 
 					// Check for updated posted values, but errors preventing them from being saved first time
@@ -476,12 +476,12 @@
 
 				$option_values = maybe_unserialize($option_values);
 				
-				for ( $k = 0; $k < count($options); $k++ ) {
+				for ( $k = 0, $l = count( $options ); $k < $l; $k++ ) {
 					$selected = '';
 					
 					// First, check to see whether the user's saved values
 					// match the option
-					for ( $j = 0; $j < count($option_values); $j++ ) {
+					for ( $j = 0, $m = count( $option_values ); $j < $m; $j++ ) {
 						if ( $option_values[$j] == $options[$k]->name || @in_array( $options[$k]->name, $value ) ) {
 							$selected = ' checked="checked"';
 							break;
@@ -618,7 +618,7 @@
 		$group_name = bp_profile_group_name(false);
 
 	$tabs = array();
-	for ( $i = 0; $i < count($groups); $i++ ) {
+	for ( $i = 0, $j = count( $groups ); $i < $j; $i++ ) {
 		if ( $group_name == $groups[$i]->name )
 			$selected = ' class="current"';
 		else
Index: bp-xprofile/bp-xprofile-classes.php
===================================================================
--- bp-xprofile/bp-xprofile-classes.php	(revision 3695)
+++ bp-xprofile/bp-xprofile-classes.php	(working copy)
@@ -61,14 +61,14 @@
 		if ( !$this->can_delete )
 			return false;
 
-		/* Delete field group */
+		// Delete field group
 		if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_groups} WHERE id = %d", $this->id ) ) ) {
 			return false;
 		} else {
-			/* Remove the group's fields. */
+			// Remove the group's fields.
 			if ( BP_XProfile_Field::delete_for_group( $this->id ) ) {
-				/* Remove profile data for the groups fields */
-				for ( $i = 0; $i < count( $this->fields ); $i++ ) {
+				// Remove profile data for the groups fields
+				for ( $i = 0, $j = count( $this->fields ); $i < $j; $i++ ) {
 					BP_XProfile_ProfileData::delete_for_field( $this->fields[$i]->id );
 				}
 			}
@@ -569,7 +569,7 @@
 				}
 
 				if ( !empty( $options ) ) {
-					for ( $i = 0; $i < count( $options ); $i++ ) {
+					for ( $i = 0, $k = count( $options ); $i < $k; $i++ ) {
 						$j = $i + 1;
 
 						if ( 'multiselectbox' == $type || 'checkbox' == $type )
@@ -889,7 +889,7 @@
 		$field_sql = '';
 
 		if ( is_array( $fields ) ) {
-			for ( $i = 0; $i < count( $fields ); $i++ ) {
+			for ( $i = 0, $j = count( $fields ); $i < $j; $i++ ) {
 				if ( $i == 0 )
 					$field_sql .= $wpdb->prepare( "AND ( f.name = %s ", $fields[$i] );
 				else
@@ -909,8 +909,8 @@
 		$new_values = array();
 
 		if ( is_array( $fields ) ) {
-			for ( $i = 0; $i < count( $values ); $i++ ) {
-				for ( $j = 0; $j < count( $fields ); $j++ ) {
+			for ( $i = 0, $k = count( $values ); $i < $k; $i++ ) {
+				for ( $j = 0, $l = count( $fields ); $j < $l; $j++ ) {
 					if ( $values[$i]->name == $fields[$j] )
 						$new_values[$fields[$j]] = $values[$i]->value;
 					else if ( !array_key_exists( $fields[$j], $new_values ) )
Index: bp-friends/bp-friends-templatetags.php
===================================================================
--- bp-friends/bp-friends-templatetags.php	(revision 3694)
+++ bp-friends/bp-friends-templatetags.php	(working copy)
@@ -41,7 +41,7 @@
 
 		<?php if ( $friend_ids ) { ?>
 			<ul class="horiz-gallery">
-			<?php for ( $i = 0; $i < count( $friend_ids ); $i++ ) { ?>
+			<?php for ( $i = 0, $j = count( $friend_ids ); $i < $j; $i++ ) { ?>
 				<li>
 					<a href="<?php echo bp_core_get_user_domain( $friend_ids[$i] ) ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $friend_ids[$i], 'type' => 'thumb' ) ) ?></a>
 					<h5><?php echo bp_core_get_userlink($friend_ids[$i]) ?></h5>
@@ -68,7 +68,7 @@
 ?>
 	<?php if ( $user_ids['users'] ) { ?>
 		<ul class="item-list" id="random-members-list">
-		<?php for ( $i = 0; $i < count( $user_ids['users'] ); $i++ ) { ?>
+		<?php for ( $i = 0, $j = count( $user_ids['users'] ); $i < $j; $i++ ) { ?>
 			<li>
 				<a href="<?php echo bp_core_get_user_domain( $user_ids['users'][$i]->user_id ) ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $user_ids['users'][$i]->user_id, 'type' => 'thumb' ) ) ?></a>
 				<h5><?php echo bp_core_get_userlink( $user_ids['users'][$i]->user_id ) ?></h5>
Index: bp-friends/bp-friends-classes.php
===================================================================
--- bp-friends/bp-friends-classes.php	(revision 3694)
+++ bp-friends/bp-friends-classes.php	(working copy)
@@ -94,7 +94,7 @@
 		$friends = $wpdb->get_results( $wpdb->prepare( "SELECT friend_user_id, initiator_user_id FROM {$bp->friends->table_name} $friend_sql $oc_sql ORDER BY date_created DESC" ) );
 		$fids = array();
 
-		for ( $i = 0; $i < count($friends); $i++ ) {
+		for ( $i = 0, $j = count( $friends ); $i < $j; $i++ ) {
 			if ( $assoc_arr )
 				$fids[] = array( 'user_id' => ( $friends[$i]->friend_user_id == $user_id ) ? $friends[$i]->initiator_user_id : $friends[$i]->friend_user_id );
 			else
@@ -276,7 +276,7 @@
 		$sql = $wpdb->prepare( "SELECT friend_user_id, initiator_user_id FROM {$bp->friends->table_name} WHERE (friend_user_id = %d || initiator_user_id = %d) && is_confirmed = 1 ORDER BY rand() LIMIT %d", $user_id, $user_id, $total_friends );
 		$results = $wpdb->get_results($sql);
 
-		for ( $i = 0; $i < count($results); $i++ ) {
+		for ( $i = 0, $j = count( $results ); $i < $j; $i++ ) {
 			$fids[] = ( $results[$i]->friend_user_id == $user_id ) ? $results[$i]->initiator_user_id : $results[$i]->friend_user_id;
 		}
 
@@ -293,7 +293,7 @@
 		$friend_ids = BP_Friends_Friendship::get_friend_user_ids( $user_id );
 
 		$invitable_count = 0;
-		for ( $i = 0; $i < count($friend_ids); $i++ ) {
+		for ( $i = 0, $j = count( $friend_ids ); $i < $j; $i++ ) {
 
 			if ( BP_Groups_Member::check_is_member( (int)$friend_ids[$i], $group_id ) )
 				continue;
Index: bp-activity/bp-activity-classes.php
===================================================================
--- bp-activity/bp-activity-classes.php	(revision 3694)
+++ bp-activity/bp-activity-classes.php	(working copy)
@@ -430,7 +430,7 @@
 
 		$activities = bp_activity_get_sitewide( array( 'max' => $limit ) );
 
-		for ( $i = 0; $i < count($activities); $i++ ) {
+		for ( $i = 0, $j = count( $activities ); $i < $j; $i++ ) {
 				$title = explode( '<span', $activities[$i]['content'] );
 
 				$activity_feed[$i]['title'] = trim( strip_tags( $title[0] ) );
Index: bp-messages.php
===================================================================
--- bp-messages.php	(revision 3694)
+++ bp-messages.php	(working copy)
@@ -448,7 +448,7 @@
 
 	if ( is_array($thread_ids) ) {
 		$error = 0;
-		for ( $i = 0; $i < count($thread_ids); $i++ ) {
+		for ( $i = 0, $j = count( $thread_ids ); $i < $j; $i++ ) {
 			if ( !$status = BP_Messages_Thread::delete($thread_ids[$i]) )
 				$error = 1;
 		}
Index: bp-forums.php
===================================================================
--- bp-forums.php	(revision 3694)
+++ bp-forums.php	(working copy)
@@ -397,13 +397,14 @@
 	if ( empty( $topics ) )
 		return $topics;
 
-	/* Get the topic ids */
-	foreach ( (array)$topics as $topic ) $topic_ids[] = $topic->topic_id;
+	// Get the topic ids
+	foreach ( (array)$topics as $topic )
+		$topic_ids[] = $topic->topic_id;
 	$topic_ids = $wpdb->escape( join( ',', (array)$topic_ids ) );
 
-	/* Fetch the topic's last poster details */
+	// Fetch the topic's last poster details
 	$poster_details = $wpdb->get_results( $wpdb->prepare( "SELECT t.topic_id, t.topic_last_poster, u.user_login, u.user_nicename, u.user_email, u.display_name FROM {$wpdb->users} u, {$bbdb->topics} t WHERE u.ID = t.topic_last_poster AND t.topic_id IN ( {$topic_ids} )" ) );
-	for ( $i = 0; $i < count( $topics ); $i++ ) {
+	for ( $i = 0, $j = count( $topics ); $i < $j; $i++ ) {
 		foreach ( (array)$poster_details as $poster ) {
 			if ( $poster->topic_id == $topics[$i]->topic_id ) {
 				$topics[$i]->topic_last_poster_email = $poster->user_email;
@@ -414,10 +415,10 @@
 		}
 	}
 
-	/* Fetch fullname for the topic's last poster */
+	// Fetch fullname for the topic's last poster
 	if ( bp_is_active( 'xprofile' ) ) {
 		$poster_names = $wpdb->get_results( $wpdb->prepare( "SELECT t.topic_id, pd.value FROM {$bp->profile->table_name_data} pd, {$bbdb->topics} t WHERE pd.user_id = t.topic_last_poster AND pd.field_id = 1 AND t.topic_id IN ( {$topic_ids} )" ) );
-		for ( $i = 0; $i < count( $topics ); $i++ ) {
+		for ( $i = 0; $i < $j; $i++ ) {
 			foreach ( (array)$poster_names as $name ) {
 				if ( $name->topic_id == $topics[$i]->topic_id )
 					$topics[$i]->topic_last_poster_displayname = $name->value;
@@ -514,14 +515,15 @@
 	if ( empty( $posts ) )
 		return $posts;
 
-	/* Get the user ids */
-	foreach ( (array)$posts as $post ) $user_ids[] = $post->poster_id;
+	// Get the user ids
+	foreach ( (array)$posts as $post )
+		$user_ids[] = $post->poster_id;
 	$user_ids = $wpdb->escape( join( ',', (array)$user_ids ) );
 
-	/* Fetch the poster's user_email, user_nicename and user_login */
+	// Fetch the poster's user_email, user_nicename and user_login
 	$poster_details = $wpdb->get_results( $wpdb->prepare( "SELECT u.ID as user_id, u.user_login, u.user_nicename, u.user_email, u.display_name FROM {$wpdb->users} u WHERE u.ID IN ( {$user_ids} )" ) );
 
-	for ( $i = 0; $i < count( $posts ); $i++ ) {
+	for ( $i = 0, $j = count( $posts ); $i < $j; $i++ ) {
 		foreach ( (array)$poster_details as $poster ) {
 			if ( $poster->user_id == $posts[$i]->poster_id ) {
 				$posts[$i]->poster_email = $poster->user_email;
@@ -532,13 +534,13 @@
 		}
 	}
 
-	/* Fetch fullname for each poster. */
+	// Fetch fullname for each poster.
 	if ( bp_is_active( 'xprofile' ) ) {
 		$poster_names = $wpdb->get_results( $wpdb->prepare( "SELECT pd.user_id, pd.value FROM {$bp->profile->table_name_data} pd WHERE pd.user_id IN ( {$user_ids} )" ) );
-		for ( $i = 0; $i < count( $posts ); $i++ ) {
+		for ( $i = 0; $i < $j; $i++ ) {
 			foreach ( (array)$poster_names as $name ) {
 				if ( isset( $topics[$i] ) && $name->user_id == $topics[$i]->user_id )
-				$posts[$i]->poster_name = $poster->value;
+					$posts[$i]->poster_name = $poster->value;
 			}
 		}
 	}
Index: bp-groups.php
===================================================================
--- bp-groups.php	(revision 3694)
+++ bp-groups.php	(working copy)
@@ -2306,7 +2306,7 @@
 	$invited_users = groups_get_invites_for_group( $user_id, $group_id );
 	$group = new BP_Groups_Group( $group_id );
 
-	for ( $i = 0; $i < count( $invited_users ); $i++ ) {
+	for ( $i = 0, $j = count( $invited_users ); $i < $j; $i++ ) {
 		$member = new BP_Groups_Member( $invited_users[$i], $group_id );
 
 		// Send the actual invite
@@ -2425,7 +2425,7 @@
 
 		require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
 
-		for ( $i = 0; $i < count( $admins ); $i++ ) {
+		for ( $i = 0, $j = count( $admins ); $i < $j; $i++ ) {
 			// Saved okay, now send the email notification
 			groups_notification_new_membership_request( $requesting_user_id, $admins[$i]->user_id, $group_id, $requesting_user->id );
 		}
Index: bp-blogs/bp-blogs-classes.php
===================================================================
--- bp-blogs/bp-blogs-classes.php	(revision 3694)
+++ bp-blogs/bp-blogs-classes.php	(working copy)
@@ -281,15 +281,15 @@
 		if ( empty( $blog_ids ) )
 			return $paged_blogs;
 
-		for ( $i = 0; $i < count( $paged_blogs ); $i++ ) {
+		for ( $i = 0, $j = count( $paged_blogs ); $i < $j; $i++ ) {
 			$blog_prefix = $wpdb->get_blog_prefix( $paged_blogs[$i]->blog_id );
 			$paged_blogs[$i]->latest_post = $wpdb->get_row( "SELECT post_title, guid FROM {$blog_prefix}posts WHERE post_status = 'publish' AND post_type = 'post' AND id != 1 ORDER BY id DESC LIMIT 1" );
 		}
 
-		/* Fetch the blog description for each blog (as it may be empty we can't fetch it in the main query). */
+		// Fetch the blog description for each blog (as it may be empty we can't fetch it in the main query).
 		$blog_descs = $wpdb->get_results( $wpdb->prepare( "SELECT blog_id, meta_value as description FROM {$bp->blogs->table_name_blogmeta} WHERE meta_key = 'description' AND blog_id IN ( {$blog_ids} )" ) );
 
-		for ( $i = 0; $i < count( $paged_blogs ); $i++ ) {
+		for ( $i = 0; $i < $j; $i++ ) {
 			foreach ( (array)$blog_descs as $desc ) {
 				if ( $desc->blog_id == $paged_blogs[$i]->blog_id )
 					$paged_blogs[$i]->description = $desc->description;
Index: bp-messages/bp-messages-classes.php
===================================================================
--- bp-messages/bp-messages-classes.php	(revision 3694)
+++ bp-messages/bp-messages-classes.php	(working copy)
@@ -172,7 +172,7 @@
 			return false;
 
 		$count = 0;
-		for ( $i = 0; $i < count($unread_counts); $i++ ) {
+		for ( $i = 0, $j = count( $unread_counts ); $i < $j; $i++ ) {
 			$count += $unread_counts[$i]->unread_count;
 		}
 
@@ -331,7 +331,7 @@
 			return false;
 
 		if ( is_array( $recipient_usernames ) ) {
-			for ( $i = 0; $i < count($recipient_usernames); $i++ ) {
+			for ( $i = 0, $j = count( $recipient_usernames ); $i < $j; $i++ ) {
 				if ( $rid = bp_core_get_userid( trim($recipient_usernames[$i]) ) )
 					$recipient_ids[] = $rid;
 			}
Index: bp-core.php
===================================================================
--- bp-core.php	(revision 3694)
+++ bp-core.php	(working copy)
@@ -1422,14 +1422,14 @@
 		$older_date = gmmktime( (int)$time_chunks[1], (int)$time_chunks[2], (int)$time_chunks[3], (int)$date_chunks[1], (int)$date_chunks[2], (int)$date_chunks[0] );
 	}
 
-	/* $newer_date will equal false if we want to know the time elapsed between a date and the current time */
-	/* $newer_date will have a value if we want to work out time elapsed between two known dates */
+	// $newer_date will equal false if we want to know the time elapsed between a date and the current time
+	// $newer_date will have a value if we want to work out time elapsed between two known dates
 	$newer_date = ( !$newer_date ) ? strtotime( bp_core_current_time() ) : $newer_date;
 
-	/* Difference in seconds */
+	// Difference in seconds
 	$since = $newer_date - $older_date;
 
-	/* Something went wrong with date calculation and we ended up with a negative date. */
+	// Something went wrong with date calculation and we ended up with a negative date.
 	if ( 0 > $since )
 		return __( 'sometime', 'buddypress' );
 
@@ -1440,11 +1440,11 @@
 	 * so there's only two bits of calculation below:
 	 */
 
-	/* Step one: the first chunk */
-	for ( $i = 0, $j = count($chunks); $i < $j; $i++) {
+	// Step one: the first chunk
+	for ( $i = 0, $j = count( $chunks ); $i < $j; $i++) {
 		$seconds = $chunks[$i][0];
 
-		/* Finding the biggest chunk (if the chunk fits, break) */
+		// Finding the biggest chunk (if the chunk fits, break)
 		if ( ( $count = floor($since / $seconds) ) != 0 )
 			break;
 	}
@@ -1453,16 +1453,16 @@
         if ( !isset( $chunks[$i] ) )
 		return '0 ' . __( 'seconds', 'buddypress' );
 
-	/* Set output var */
+	// Set output var
 	$output = ( 1 == $count ) ? '1 '. $chunks[$i][1] : $count . ' ' . $chunks[$i][2];
 
-	/* Step two: the second chunk */
+	// Step two: the second chunk
 	if ( $i + 2 < $j ) {
 		$seconds2 = $chunks[$i + 1][0];
 		$name2 = $chunks[$i + 1][1];
 
 		if ( ( $count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 ) ) != 0 ) {
-			/* Add to output var */
+			// Add to output var
 			$output .= ( 1 == $count2 ) ? _x( ',', 'Separator in time since', 'buddypress' ) . ' 1 '. $chunks[$i + 1][1] : _x( ',', 'Separator in time since', 'buddypress' ) . ' ' . $count2 . ' ' . $chunks[$i + 1][2];
 		}
 	}
Index: bp-groups/bp-groups-classes.php
===================================================================
--- bp-groups/bp-groups-classes.php	(revision 3694)
+++ bp-groups/bp-groups-classes.php	(working copy)
@@ -525,9 +525,9 @@
 		if ( empty( $group_ids ) )
 			return $paged_groups;
 
-		/* Fetch the logged in users status within each group */
+		// Fetch the logged in users status within each group
 		$user_status = $wpdb->get_col( $wpdb->prepare( "SELECT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id IN ( {$group_ids} ) AND is_confirmed = 1 AND is_banned = 0", $bp->loggedin_user->id ) );
-		for ( $i = 0; $i < count( $paged_groups ); $i++ ) {
+		for ( $i = 0, $j = count( $paged_groups ); $i < $j; $i++ ) {
 			$paged_groups[$i]->is_member = false;
 
 			foreach ( (array)$user_status as $group_id ) {
@@ -537,7 +537,7 @@
 		}
 
 		$user_banned = $wpdb->get_col( $wpdb->prepare( "SELECT group_id FROM {$bp->groups->table_name_members} WHERE is_banned = 1 AND user_id = %d AND group_id IN ( {$group_ids} )", $bp->loggedin_user->id ) );
-		for ( $i = 0; $i < count( $paged_groups ); $i++ ) {
+		for ( $i = 0; $i < $j; $i++ ) {
 			$paged_groups[$i]->is_banned = false;
 
 			foreach ( (array)$user_banned as $group_id ) {
@@ -1034,13 +1034,14 @@
 		else
 			$total_member_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(user_id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_admins_sql} {$exclude_sql}", $group_id ) );
 
-		/* Fetch whether or not the user is a friend */
-		foreach ( (array)$members as $user ) $user_ids[] = $user->user_id;
+		// Fetch whether or not the user is a friend
+		foreach ( (array)$members as $user )
+			$user_ids[] = $user->user_id;
 		$user_ids = $wpdb->escape( join( ',', (array)$user_ids ) );
 
 		if ( bp_is_active( 'friends' ) ) {
 			$friend_status = $wpdb->get_results( $wpdb->prepare( "SELECT initiator_user_id, friend_user_id, is_confirmed FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d AND friend_user_id IN ( {$user_ids} ) ) OR (initiator_user_id IN ( {$user_ids} ) AND friend_user_id = %d )", $bp->loggedin_user->id, $bp->loggedin_user->id ) );
-			for ( $i = 0; $i < count( $members ); $i++ ) {
+			for ( $i = 0, $j = count( $members ); $i < $j; $i++ ) {
 				foreach ( (array)$friend_status as $status ) {
 					if ( $status->initiator_user_id == $members[$i]->user_id || $status->friend_user_id == $members[$i]->user_id )
 						$members[$i]->is_friend = $status->is_confirmed;
Index: bp-groups/bp-groups-templatetags.php
===================================================================
--- bp-groups/bp-groups-templatetags.php	(revision 3694)
+++ bp-groups/bp-groups-templatetags.php	(working copy)
@@ -1856,7 +1856,7 @@
 		if ( $friends ) {
 			$invites = groups_get_invites_for_group( $bp->loggedin_user->id, $group_id );
 
-			for ( $i = 0; $i < count( $friends ); $i++ ) {
+			for ( $i = 0, $j = count( $friends ); $i < $j; $i++ ) {
 				$checked = '';
 
 				if ( !empty( $invites ) ) {
