Index: /trunk/bp-activity.php
===================================================================
--- /trunk/bp-activity.php	(revision 3727)
+++ /trunk/bp-activity.php	(revision 3728)
@@ -1,3 +1,5 @@
 <?php
+
+// Required Files
 require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-classes.php' );
 require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-templatetags.php' );
@@ -7,15 +9,21 @@
 	global $bp, $current_blog;
 
+	// Define a slug, if necessary
 	if ( !defined( 'BP_ACTIVITY_SLUG' ) )
-		define ( 'BP_ACTIVITY_SLUG', $bp->pages->activity->slug );
+		define( 'BP_ACTIVITY_SLUG', bp_core_component_slug_from_root_slug( $bp->pages->activity->slug ) ); 
 
 	// For internal identification
-	$bp->activity->id = 'activity';
+	$bp->activity->id   = 'activity';
 	$bp->activity->name = $bp->pages->activity->name;
-	$bp->activity->slug = BP_ACTIVITY_SLUG;
-
+
+	// Slugs
+	$bp->activity->slug      = BP_ACTIVITY_SLUG;
+	$bp->activity->root_slug = $bp->pages->activity->slug;
+
+	// Tables
 	$bp->activity->table_name      = $bp->table_prefix . 'bp_activity';
 	$bp->activity->table_name_meta = $bp->table_prefix . 'bp_activity_meta';
 
+	// Notifications
 	$bp->activity->format_notification_function = 'bp_activity_format_notifications';
 
@@ -38,5 +46,5 @@
 	$user_domain = ( isset( $bp->displayed_user->domain ) ) ? $bp->displayed_user->domain : $bp->loggedin_user->domain;
 	$user_login = ( isset( $bp->displayed_user->userdata->user_login ) ) ? $bp->displayed_user->userdata->user_login : $bp->loggedin_user->userdata->user_login;
-	$activity_link = $user_domain . $bp->activity->name . '/';
+	$activity_link = $user_domain . $bp->activity->slug . '/';
 
 	/* Add the subnav items to the activity nav item if we are using a theme that supports this */
@@ -44,8 +52,8 @@
 
 	if ( bp_is_active( 'friends' ) )
-		bp_core_new_subnav_item( array( 'name' => __( 'Friends', 'buddypress' ), 'slug' => BP_FRIENDS_SLUG, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->name, 'screen_function' => 'bp_activity_screen_friends', 'position' => 20, 'item_css_id' => 'activity-friends' ) );
+		bp_core_new_subnav_item( array( 'name' => __( 'Friends', 'buddypress' ), 'slug' => BP_FRIENDS_SLUG, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_friends', 'position' => 20, 'item_css_id' => 'activity-friends' ) );
 
 	if ( bp_is_active( 'groups' ) )
-		bp_core_new_subnav_item( array( 'name' => __( 'Groups', 'buddypress' ), 'slug' => BP_GROUPS_SLUG, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->name, 'screen_function' => 'bp_activity_screen_groups', 'position' => 30, 'item_css_id' => 'activity-groups' ) );
+		bp_core_new_subnav_item( array( 'name' => __( 'Groups', 'buddypress' ), 'slug' => BP_GROUPS_SLUG, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_groups', 'position' => 30, 'item_css_id' => 'activity-groups' ) );
 
 	bp_core_new_subnav_item( array( 'name' => __( 'Favorites', 'buddypress' ), 'slug' => 'favorites', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->name, 'screen_function' => 'bp_activity_screen_favorites', 'position' => 40, 'item_css_id' => 'activity-favs' ) );
@@ -60,5 +68,5 @@
 		}
 	}
-
+	
 	do_action( 'bp_activity_setup_nav' );
 }
Index: /trunk/bp-activity/bp-activity-templatetags.php
===================================================================
--- /trunk/bp-activity/bp-activity-templatetags.php	(revision 3727)
+++ /trunk/bp-activity/bp-activity-templatetags.php	(revision 3728)
@@ -176,38 +176,37 @@
 
 	// The default scope should recognize custom slugs
-	if ( array_key_exists( $bp->current_action, (array)$bp->active_components ) ) {
+	if ( array_key_exists( $bp->current_action, (array)$bp->active_components ) )
 		$scope = $bp->active_components[$bp->current_action];
-	} else {
+	else
 		$scope = $bp->current_action;
-	}
-
-	/* Support for permalinks on single item pages: /groups/my-group/activity/124/ */
+
+	// Support for permalinks on single item pages: /groups/my-group/activity/124/
 	if ( $bp->current_action == $bp->activity->slug )
 		$include = $bp->action_variables[0];
 
-	/* Note: any params used for filtering can be a single value, or multiple values comma separated. */
+	// Note: any params used for filtering can be a single value, or multiple values comma separated.
 	$defaults = array(
-		'display_comments' => 'threaded', // false for none, stream/threaded - show comments in the stream or threaded under items
-		'include' => $include, // pass an activity_id or string of IDs comma-separated
-		'exclude' => $exclude, // pass an activity_id or string of IDs comma-separated
-		'in' => $in, // comma-separated list or array of activity IDs among which to search
-		'sort' => 'DESC', // sort DESC or ASC
-		'page' => 1, // which page to load
-		'per_page' => 20, // number of items per page
-		'max' => false, // max number to return
-		'show_hidden' => $show_hidden, // Show activity items that are hidden site-wide?
-
-		/* Scope - pre-built activity filters for a user (friends/groups/favorites/mentions) */
-		'scope' => $bp->current_action,
-
-		/* Filtering */
-		'user_id' => $user_id, // user_id to filter on
-		'object' => $object, // object to filter on e.g. groups, profile, status, friends
-		'action' => false, // action to filter on e.g. activity_update, new_forum_post, profile_updated
-		'primary_id' => $primary_id, // object ID to filter on e.g. a group_id or forum_id or blog_id etc.
-		'secondary_id' => false, // secondary object ID to filter on e.g. a post_id
-
-		/* Searching */
-		'search_terms' => false // specify terms to search on
+		'display_comments' => 'threaded',   // false for none, stream/threaded - show comments in the stream or threaded under items
+		'include'          => $include,     // pass an activity_id or string of IDs comma-separated
+		'exclude'          => $exclude,     // pass an activity_id or string of IDs comma-separated
+		'in'               => $in,          // comma-separated list or array of activity IDs among which to search
+		'sort'             => 'DESC',       // sort DESC or ASC
+		'page'             => 1,            // which page to load
+		'per_page'         => 20,           // number of items per page
+		'max'              => false,        // max number to return
+		'show_hidden'      => $show_hidden, // Show activity items that are hidden site-wide?
+
+		// Scope - pre-built activity filters for a user (friends/groups/favorites/mentions)
+		'scope'            => $scope,
+
+		// Filtering
+		'user_id'          => $user_id,     // user_id to filter on
+		'object'           => $object,      // object to filter on e.g. groups, profile, status, friends
+		'action'           => false,        // action to filter on e.g. activity_update, new_forum_post, profile_updated
+		'primary_id'       => $primary_id,  // object ID to filter on e.g. a group_id or forum_id or blog_id etc.
+		'secondary_id'     => false,        // secondary object ID to filter on e.g. a post_id
+
+		// Searching
+		'search_terms'     => false         // specify terms to search on
 	);
 
@@ -215,5 +214,5 @@
 	extract( $r );
 
-	/* If you have passed a "scope" then this will override any filters you have passed. */
+	// If you have passed a "scope" then this will override any filters you have passed.
 	if ( 'just-me' == $scope || 'friends' == $scope || 'groups' == $scope || 'favorites' == $scope || 'mentions' == $scope ) {
 		if ( 'just-me' == $scope )
@@ -272,10 +271,11 @@
 	}
 
-	/* Support for basic filters in earlier BP versions. */
-	$filter = false;
+	// Support for basic filters in earlier BP versions.
 	if ( isset( $_GET['afilter'] ) )
 		$filter = array( 'object' => $_GET['afilter'] );
 	else if ( !empty( $user_id ) || !empty( $object ) || !empty( $action ) || !empty( $primary_id ) || !empty( $secondary_id ) )
 		$filter = array( 'user_id' => $user_id, 'object' => $object, 'action' => $action, 'primary_id' => $primary_id, 'secondary_id' => $secondary_id );
+	else
+		$filter = false;
 
 	$activities_template = new BP_Activity_Template( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden, $exclude, $in );
Index: /trunk/bp-blogs.php
===================================================================
--- /trunk/bp-blogs.php	(revision 3727)
+++ /trunk/bp-blogs.php	(revision 3728)
@@ -1,7 +1,9 @@
 <?php
+
+// Required Files
 require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-classes.php' );
 require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-templatetags.php' );
 
-/* Include the sitewide blog posts widget if this is a multisite installation */
+// Include the sitewide blog posts widget if this is a multisite installation
 if ( is_multisite() )
 	require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-widgets.php' );
@@ -11,20 +13,25 @@
 
 	if ( !defined( 'BP_BLOGS_SLUG' ) && isset( $bp->pages->blogs->slug ) )
-		define ( 'BP_BLOGS_SLUG', $bp->pages->blogs->slug );
-	elseif( !defined( 'BP_BLOGS_SLUG' ) )
+		define ( 'BP_BLOGS_SLUG', bp_core_component_slug_from_root_slug( $bp->pages->blogs->slug ) );
+	else if( !defined( 'BP_BLOGS_SLUG' ) )
 		define ( 'BP_BLOGS_SLUG', 'blogs' );
 
 	// For internal identification
-	$bp->blogs->id = 'blogs';
-
-	$bp->blogs->slug = BP_BLOGS_SLUG;
-
+	$bp->blogs->id   = 'blogs';
+	$bp->blogs->name = $bp->pages->blogs->name;
+
+	// Slugs
+	$bp->blogs->slug      = BP_BLOGS_SLUG;
+	$bp->blogs->root_slug = $bp->pages->blogs->slug;
+
+	// Tables
 	$bp->blogs->table_name          = $bp->table_prefix . 'bp_user_blogs';
 	$bp->blogs->table_name_blogmeta = $bp->table_prefix . 'bp_user_blogs_blogmeta';
 
-	$bp->blogs->format_notification_function = 'bp_blogs_format_notifications';
+	// Notifications
+	$bp->blogs->format_notification_function      = 'bp_blogs_format_notifications';
 
 	// Register this in the active components array
-	$bp->active_components[$bp->blogs->slug] = $bp->blogs->id;
+	$bp->active_components[$bp->blogs->slug]      = $bp->blogs->id;
 
 	// The default text for the blogs directory search box
@@ -36,6 +43,4 @@
 
 /**
- * bp_blogs_setup_nav()
- *
  * Adds "Blog" to the navigation arrays for the current and logged in user.
  *
@@ -47,15 +52,18 @@
 	global $bp;
 
-	/* Blog/post/comment menus should not appear on single WordPress setups. Although comments
-	   and posts made by users will still show on their activity stream .*/
+	/**
+	 * Blog/post/comment menus should not appear on single WordPress setups.
+	 * Although comments and posts made by users will still show on their
+	 * activity stream.
+	 */
 	if ( !is_multisite() )
 		return false;
 
-	/* Add 'Blogs' to the main navigation */
+	// Add 'Blogs' to the main navigation
 	bp_core_new_nav_item( array( 'name' => sprintf( __( 'Blogs <span>(%d)</span>', 'buddypress' ), bp_blogs_total_blogs_for_user() ), 'slug' => $bp->blogs->slug, 'position' => 30, 'screen_function' => 'bp_blogs_screen_my_blogs', 'default_subnav_slug' => 'my-blogs', 'item_css_id' => $bp->blogs->id ) );
 
 	$blogs_link = $bp->loggedin_user->domain . $bp->blogs->slug . '/';
 
-	/* Set up the component options navigation for Blog */
+	// Set up the component options navigation for Blog
 	if ( $bp->blogs->slug == $bp->current_component ) {
 		if ( bp_is_my_profile() ) {
@@ -64,5 +72,6 @@
 			}
 		} else {
-			/* If we are not viewing the logged in user, set up the current users avatar and name */
+			// If we are not viewing the logged in user, set up the current
+			// users avatar and name
 			$bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
 			$bp->bp_options_title = $bp->displayed_user->fullname;
@@ -87,5 +96,5 @@
 
 
-/********************************************************************************
+/*******************************************************************************
  * Screen Functions
  *
@@ -117,9 +126,8 @@
 	bp_core_load_template( apply_filters( 'bp_blogs_template_create_a_blog', 'blogs/create' ) );
 }
-/* The create screen is not attached to a nav item, so we need to attach it to an action */
 add_action( 'wp', 'bp_blogs_screen_create_a_blog', 3 );
 
 
-/********************************************************************************
+/*******************************************************************************
  * Activity & Notification Functions
  *
@@ -148,20 +156,23 @@
 		return false;
 
-	/* Because blog, comment, and blog post code execution happens before anything else
-	   we may need to manually instantiate the activity component globals */
+	/**
+	 * Because blog, comment, and blog post code execution happens before
+	 * anything else we may need to manually instantiate the activity
+	 * component globals.
+	 */
 	if ( !$bp->activity && function_exists('bp_activity_setup_globals') )
 		bp_activity_setup_globals();
 
 	$defaults = array(
-		'user_id' => $bp->loggedin_user->id,
-		'action' => '',
-		'content' => '',
-		'primary_link' => '',
-		'component' => $bp->blogs->id,
-		'type' => false,
-		'item_id' => false,
+		'user_id'           => $bp->loggedin_user->id,
+		'action'            => '',
+		'content'           => '',
+		'primary_link'      => '',
+		'component'         => $bp->blogs->id,
+		'type'              => false,
+		'item_id'           => false,
 		'secondary_item_id' => false,
-		'recorded_time' => bp_core_current_time(),
-		'hide_sitewide' => false
+		'recorded_time'     => bp_core_current_time(),
+		'hide_sitewide'     => false
 	);
 
@@ -169,5 +180,5 @@
 	extract( $r, EXTR_SKIP );
 
-	/* Remove large images and replace them with just one image thumbnail */
+	// Remove large images and replace them with just one image thumbnail
  	if ( function_exists( 'bp_activity_thumbnail_content_images' ) && !empty( $content ) )
 		$content = bp_activity_thumbnail_content_images( $content, $primary_link );
@@ -179,5 +190,5 @@
 		$content = apply_filters( 'bp_blogs_record_activity_content', bp_create_excerpt( $content ), $content );
 
-	/* Check for an existing entry and update if one exists. */
+	// Check for an existing entry and update if one exists.
 	$id = bp_activity_get_activity_id( array(
 		'user_id' => $user_id,
@@ -194,10 +205,10 @@
 	global $bp;
 
-	if ( function_exists('bp_activity_delete_by_item_id') ) {
+	if ( function_exists( 'bp_activity_delete_by_item_id' ) ) {
 		$defaults = array(
-			'item_id' => false,
-			'component' => $bp->blogs->id,
-			'type' => false,
-			'user_id' => false,
+			'item_id'           => false,
+			'component'         => $bp->blogs->id,
+			'type'              => false,
+			'user_id'           => false,
 			'secondary_item_id' => false
 		);
@@ -229,10 +240,9 @@
 
 	$defaults = array(
-		'type' => 'active', // active, alphabetical, newest, or random.
-		'user_id' => false, // Pass a user_id to limit to only blogs that this user has privilages higher than subscriber on.
-		'search_terms' => false, // Limit to blogs that match these search terms
-
-		'per_page' => 20, // The number of results to return per page
-		'page' => 1, // The page to return if limiting per page
+		'type'         => 'active', // active, alphabetical, newest, or random
+		'user_id'      => false,    // Pass a user_id to limit to only blogs that this user has privilages higher than subscriber on
+		'search_terms' => false,    // Limit to blogs that match these search terms
+		'per_page'     => 20,       // The number of results to return per page
+		'page'         => 1,        // The page to return if limiting per page
 	);
 
@@ -246,5 +256,5 @@
 	global $bp, $wpdb;
 
-	/* Truncate user blogs table and re-record. */
+	// Truncate user blogs table and re-record.
 	$wpdb->query( "TRUNCATE TABLE {$bp->blogs->table_name}" );
 
@@ -320,6 +330,4 @@
 
 /**
- * bp_blogs_update_option_blogname()
- *
  * Updates blogname in BuddyPress blogmeta table
  *
@@ -330,4 +338,5 @@
 function bp_blogs_update_option_blogname( $oldvalue, $newvalue ) {
 	global $wpdb;
+
 	bp_blogs_update_blogmeta( $wpdb->blogid, 'name', $newvalue );
 }
@@ -335,6 +344,4 @@
 
 /**
- * bp_blogs_update_option_blogdescription()
- *
  * Updates blogdescription in BuddyPress blogmeta table
  *
@@ -345,4 +352,5 @@
 function bp_blogs_update_option_blogdescription( $oldvalue, $newvalue ) {
 	global $wpdb;
+
 	bp_blogs_update_blogmeta( $wpdb->blogid, 'description', $newvalue );
 }
@@ -380,5 +388,5 @@
 
 			bp_blogs_record_activity( array(
-				'user_id'            => (int)$post->post_author,
+				'user_id'           => (int)$post->post_author,
 				'action'            => apply_filters( 'bp_blogs_activity_new_post_action', $activity_action, &$post, $post_permalink ),
 				'content'           => apply_filters( 'bp_blogs_activity_new_post_content', $activity_content, &$post, $post_permalink ),
@@ -402,6 +410,4 @@
 
 /**
- * bp_blogs_record_comment()
- *
  * Record blog comment activity. Checks if blog is public and post is not
  * password protected.
@@ -428,5 +434,5 @@
 
 	// Get the user_id from the comment author email.
-	$user = get_user_by_email( $recorded_comment->comment_author_email );
+	$user    = get_user_by_email( $recorded_comment->comment_author_email );
 	$user_id = (int)$user->ID;
 
@@ -436,5 +442,5 @@
 
 	// Get blog and post data
-	$blog_id = (int)$wpdb->blogid;
+	$blog_id                = (int)$wpdb->blogid;
 	$recorded_comment->post = get_post( $recorded_comment->comment_post_ID );
 
@@ -451,9 +457,8 @@
 
 		// Prepare to record in activity streams
-		if ( is_multisite() ) {
-			$activity_action	= sprintf( __( '%1$s commented on the blog post %2$s on the blog %3$s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $post_permalink . '">' . apply_filters( 'the_title', $recorded_comment->post->post_title ) . '</a>', '<a href="' . get_blog_option( $blog_id, 'home' ) . '">' . get_blog_option( $blog_id, 'blogname' ) . '</a>' );
-		} else {
-			$activity_action	= sprintf( __( '%1$s commented on the blog post %2$s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $post_permalink . '">' . apply_filters( 'the_title', $recorded_comment->post->post_title ) . '</a>' );
-		}
+		if ( is_multisite() )
+			$activity_action = sprintf( __( '%1$s commented on the blog post %2$s on the blog %3$s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $post_permalink . '">' . apply_filters( 'the_title', $recorded_comment->post->post_title ) . '</a>', '<a href="' . get_blog_option( $blog_id, 'home' ) . '">' . get_blog_option( $blog_id, 'blogname' ) . '</a>' );
+		else
+			$activity_action = sprintf( __( '%1$s commented on the blog post %2$s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $post_permalink . '">' . apply_filters( 'the_title', $recorded_comment->post->post_title ) . '</a>' );
 
 		$activity_content	= $recorded_comment->comment_content;
@@ -478,5 +483,5 @@
 }
 add_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 );
-add_action( 'edit_comment', 'bp_blogs_record_comment', 10 );
+add_action( 'edit_comment', 'bp_blogs_record_comment', 10    );
 
 function bp_blogs_manage_comment( $comment_id, $comment_status ) {
@@ -509,6 +514,6 @@
 }
 add_action( 'add_user_to_blog', 'bp_blogs_add_user_to_blog', 10, 3 );
-add_action( 'profile_update', 'bp_blogs_add_user_to_blog' );
-add_action( 'user_register', 'bp_blogs_add_user_to_blog' );
+add_action( 'profile_update',   'bp_blogs_add_user_to_blog'        );
+add_action( 'user_register',    'bp_blogs_add_user_to_blog'        );
 
 function bp_blogs_remove_user_from_blog( $user_id, $blog_id = false ) {
@@ -605,5 +610,5 @@
 	global $bp;
 
-	/* If this is regular blog, delete all data for that blog. */
+	// If this is regular blog, delete all data for that blog.
 	BP_Blogs_Blog::delete_blog_for_all( $blog_id );
 
@@ -643,10 +648,12 @@
 
 
-//
-// Blog meta functions
-// These functions are used to store specific blogmeta in one global table, rather than in each
-// blog's options table. Significantly speeds up global blog queries.
-// By default each blog's name, description and last updated time are stored and synced here.
-//
+/*******************************************************************************
+ * Blog meta functions
+ *
+ * These functions are used to store specific blogmeta in one global table,
+ * rather than in each blog's options table. Significantly speeds up global blog
+ * queries. By default each blog's name, description and last updated time are
+ * stored and synced here.
+ */
 
 function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = false ) {
@@ -663,11 +670,10 @@
 	$meta_value = trim( $meta_value );
 
-	if ( !$meta_key ) {
+	if ( !$meta_key )
 		$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d", $blog_id ) );
-	} else if ( $meta_value ) {
+	else if ( $meta_value )
 		$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s AND meta_value = %s", $blog_id, $meta_key, $meta_value ) );
-	} else {
+	else
 		$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s", $blog_id, $meta_key ) );
-	}
 
 	wp_cache_delete( 'bp_blogs_blogmeta_' . $blog_id . '_' . $meta_key, 'bp' );
@@ -723,17 +729,15 @@
 	$meta_value = maybe_serialize($meta_value);
 
-	if (empty($meta_value)) {
+	if (empty( $meta_value ) )
 		return bp_blogs_delete_blogmeta( $blog_id, $meta_key );
-	}
 
 	$cur = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s", $blog_id, $meta_key ) );
 
-	if ( !$cur ) {
+	if ( !$cur )
 		$wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name_blogmeta} ( blog_id, meta_key, meta_value ) VALUES ( %d, %s, %s )", $blog_id, $meta_key, $meta_value ) );
-	} else if ( $cur->meta_value != $meta_value ) {
+	else if ( $cur->meta_value != $meta_value )
 		$wpdb->query( $wpdb->prepare( "UPDATE {$bp->blogs->table_name_blogmeta} SET meta_value = %s WHERE blog_id = %d AND meta_key = %s", $meta_value, $blog_id, $meta_key ) );
-	} else {
-		return false;
-	}
+	else
+		return false;
 
 	wp_cache_set( 'bp_blogs_blogmeta_' . $blog_id . '_' . $meta_key, $meta_value, 'bp' );
@@ -746,15 +750,15 @@
 		return false;
 
-	/* If this is regular blog, delete all data for that blog. */
+	// If this is regular blog, delete all data for that blog.
 	BP_Blogs_Blog::delete_blogs_for_user( $user_id );
 
 	do_action( 'bp_blogs_remove_data', $user_id );
 }
-add_action( 'wpmu_delete_user', 'bp_blogs_remove_data' );
-add_action( 'delete_user', 'bp_blogs_remove_data' );
+add_action( 'wpmu_delete_user',  'bp_blogs_remove_data' );
+add_action( 'delete_user',       'bp_blogs_remove_data' );
 add_action( 'bp_make_spam_user', 'bp_blogs_remove_data' );
 
 
-/********************************************************************************
+/*******************************************************************************
  * Caching
  *
@@ -775,16 +779,16 @@
 // List actions to clear object caches on
 add_action( 'bp_blogs_remove_blog_for_user', 'bp_blogs_clear_blog_object_cache', 10, 2 );
-add_action( 'bp_blogs_new_blog', 'bp_blogs_format_clear_blog_cache', 10, 2 );
+add_action( 'bp_blogs_new_blog',             'bp_blogs_format_clear_blog_cache', 10, 2 );
 
 // List actions to clear super cached pages on, if super cache is installed
 add_action( 'bp_blogs_remove_data_for_blog', 'bp_core_clear_cache' );
-add_action( 'bp_blogs_remove_comment', 'bp_core_clear_cache' );
-add_action( 'bp_blogs_remove_post', 'bp_core_clear_cache' );
+add_action( 'bp_blogs_remove_comment',       'bp_core_clear_cache' );
+add_action( 'bp_blogs_remove_post',          'bp_core_clear_cache' );
 add_action( 'bp_blogs_remove_blog_for_user', 'bp_core_clear_cache' );
-add_action( 'bp_blogs_remove_blog', 'bp_core_clear_cache' );
-add_action( 'bp_blogs_new_blog_comment', 'bp_core_clear_cache' );
-add_action( 'bp_blogs_new_blog_post', 'bp_core_clear_cache' );
-add_action( 'bp_blogs_new_blog', 'bp_core_clear_cache' );
-add_action( 'bp_blogs_remove_data', 'bp_core_clear_cache' );
+add_action( 'bp_blogs_remove_blog',          'bp_core_clear_cache' );
+add_action( 'bp_blogs_new_blog_comment',     'bp_core_clear_cache' );
+add_action( 'bp_blogs_new_blog_post',        'bp_core_clear_cache' );
+add_action( 'bp_blogs_new_blog',             'bp_core_clear_cache' );
+add_action( 'bp_blogs_remove_data',          'bp_core_clear_cache' );
 
 ?>
Index: /trunk/bp-core.php
===================================================================
--- /trunk/bp-core.php	(revision 3727)
+++ /trunk/bp-core.php	(revision 3728)
@@ -9,12 +9,12 @@
 define( 'BP_PLUGIN_URL', plugins_url( $path = '/buddypress' ) );
 
-/* Load the WP abstraction file so BuddyPress can run on all WordPress setups. */
+// Load the WP abstraction file so BuddyPress can run on all WordPress setups.
 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-wpabstraction.php' );
 
-/* Place your custom code (actions/filters) in a file called /plugins/bp-custom.php and it will be loaded before anything else. */
+// Place your custom code (actions/filters) in a file called /plugins/bp-custom.php and it will be loaded before anything else.
 if ( file_exists( WP_PLUGIN_DIR . '/bp-custom.php' ) )
 	require( WP_PLUGIN_DIR . '/bp-custom.php' );
 
-/* Define the user and usermeta table names, useful if you are using custom or shared tables. */
+// Define the user and usermeta table names, useful if you are using custom or shared tables.
 if ( !defined( 'CUSTOM_USER_TABLE' ) )
 	define( 'CUSTOM_USER_TABLE', $wpdb->base_prefix . 'users' );
@@ -25,32 +25,29 @@
 // The search slug has to be defined nice and early because of the way search requests are loaded
 if ( !defined( 'BP_SEARCH_SLUG' ) )
-        define( 'BP_SEARCH_SLUG', 'search' );
-
-/* Load the files containing functions that we globally will need. */
-require ( BP_PLUGIN_DIR . '/bp-core/bp-core-catchuri.php' );
-require ( BP_PLUGIN_DIR . '/bp-core/bp-core-classes.php' );
-require ( BP_PLUGIN_DIR . '/bp-core/bp-core-filters.php' );
-require ( BP_PLUGIN_DIR . '/bp-core/bp-core-cssjs.php' );
-require ( BP_PLUGIN_DIR . '/bp-core/bp-core-avatars.php' );
-require ( BP_PLUGIN_DIR . '/bp-core/bp-core-templatetags.php' );
-require ( BP_PLUGIN_DIR . '/bp-core/bp-core-settings.php' );
-require ( BP_PLUGIN_DIR . '/bp-core/bp-core-widgets.php' );
+	define( 'BP_SEARCH_SLUG', 'search' );
+
+// Load the files containing functions that we globally will need.
+require ( BP_PLUGIN_DIR . '/bp-core/bp-core-catchuri.php'      );
+require ( BP_PLUGIN_DIR . '/bp-core/bp-core-classes.php'       );
+require ( BP_PLUGIN_DIR . '/bp-core/bp-core-filters.php'       );
+require ( BP_PLUGIN_DIR . '/bp-core/bp-core-cssjs.php'         );
+require ( BP_PLUGIN_DIR . '/bp-core/bp-core-avatars.php'       );
+require ( BP_PLUGIN_DIR . '/bp-core/bp-core-templatetags.php'  );
+require ( BP_PLUGIN_DIR . '/bp-core/bp-core-settings.php'      );
+require ( BP_PLUGIN_DIR . '/bp-core/bp-core-widgets.php'       );
 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-notifications.php' );
-require ( BP_PLUGIN_DIR . '/bp-core/bp-core-signup.php' );
-
-/* If BP_DISABLE_ADMIN_BAR is defined, do not load the global admin bar. */
+require ( BP_PLUGIN_DIR . '/bp-core/bp-core-signup.php'        );
+require ( BP_PLUGIN_DIR . '/bp-core/bp-core-deprecated.php'    );
+
+// If BP_DISABLE_ADMIN_BAR is defined, do not load the global admin bar.
 if ( !defined( 'BP_DISABLE_ADMIN_BAR' ) )
 	require ( BP_PLUGIN_DIR . '/bp-core/bp-core-adminbar.php' );
 
-/* Register BuddyPress themes contained within the bp-theme folder */
+// Register BuddyPress themes contained within the bp-theme folder
 register_theme_directory( WP_PLUGIN_DIR . '/buddypress/bp-themes' );
 
-
-/* "And now for something completely different" .... */
-
-
-/**
- * bp_core_setup_globals()
- *
+/** "And now for something completely different" ******************************/
+
+/**
  * Sets up default global BuddyPress configuration settings and stores
  * them in a $bp variable.
@@ -76,12 +73,15 @@
 
 	// The domain for the root of the site where the main blog resides
-	$bp->root_domain = bp_core_get_root_domain();
+	$bp->root_domain  = bp_core_get_root_domain();
 
 	// The names of the core WordPress pages used to display BuddyPress content
-	$bp->pages = $bp_pages;
+	$bp->pages        = $bp_pages;
+
+	/** Members Component *****************************************************/
 
 	// Set up the members id and active components entry
-	$bp->members->id = 'members';
-
+	$bp->members->id  = 'members';
+
+	// Members Slugs
 	$bp->members->slug = $bp->pages->members->slug;
 	$bp->active_components[$bp->members->slug] = $bp->members->id;
@@ -89,4 +89,6 @@
 	// The user ID of the user who is currently logged in.
 	$bp->loggedin_user->id = $current_user->ID;
+
+	/** Logged in user ********************************************************/
 
 	// The domain for the user currently logged in. eg: http://domain.com/members/andy
@@ -100,4 +102,6 @@
 	$bp->loggedin_user->is_site_admin  = $bp->loggedin_user->is_super_admin; // deprecated 1.2.6
 
+	/** Displayed user ********************************************************/
+
 	// The user id of the user currently being viewed, set in /bp-core/bp-core-catchuri.php
 	$bp->displayed_user->id = $displayed_user_id;
@@ -109,4 +113,6 @@
 	$bp->displayed_user->userdata = bp_core_get_core_userdata( $bp->displayed_user->id );
 
+	/** Component and Action **************************************************/
+
 	// The component being used eg: http://domain.com/members/andy/ [profile]
 	$bp->current_component = $current_component; // type: string
@@ -121,5 +127,6 @@
 	$bp->current_item = ''; // type: string
 
-	// Used for overriding the 2nd level navigation menu so it can be used to display custom navigation for an item (for example a group)
+	// Used for overriding the 2nd level navigation menu so it can be used to
+	// display custom navigation for an item (for example a group)
 	$bp->is_single_item = false;
 
@@ -134,15 +141,20 @@
 	}
 
-	// Fetches all of the core database based BuddyPress settings in one foul swoop
+	// Fetches all of the core BuddyPress settings in one fell swoop
 	$bp->site_options = bp_core_get_site_options();
 
-	// Sets up the array container for the component navigation rendered by bp_get_nav()
+	// Sets up the array container for the component navigation rendered
+	// by bp_get_nav()
 	$bp->bp_nav = array();
 
-	// Sets up the array container for the component options navigation rendered by bp_get_options_nav()
+	// Sets up the array container for the component options navigation
+	// rendered by bp_get_options_nav()
 	$bp->bp_options_nav = array();
 
-	// Contains an array of all the active components. The key is the slug, value the internal ID of the component
+	// Contains an array of all the active components. The key is the slug,
+	// value the internal ID of the component.
 	$bp->active_components = array();
+
+	/** Avatars ***************************************************************/
 
 	// Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar
@@ -155,8 +167,10 @@
 	$bp->displayed_user->fullname = bp_core_get_user_displayname( $bp->displayed_user->id );
 
-	/* Used to determine if user has admin rights on current content. If the logged in user is viewing
-	   their own profile and wants to delete something, is_item_admin is used. This is a
-	   generic variable so it can be used by other components. It can also be modified, so when viewing a group
-	   'is_item_admin' would be 1 if they are a group admin, 0 if they are not. */
+	/**
+	 * Used to determine if user has admin rights on current content. If the logged in user is viewing
+	 * their own profile and wants to delete something, is_item_admin is used. This is a
+	 * generic variable so it can be used by other components. It can also be modified, so when viewing a group
+	 * 'is_item_admin' would be 1 if they are a group admin, 0 if they are not.
+	 */
 	$bp->is_item_admin = bp_user_has_access();
 
@@ -164,11 +178,13 @@
 	$bp->is_item_mod = false;
 
+	// Notifications Table
 	$bp->core->table_name_notifications = $bp->table_prefix . 'bp_notifications';
 
+	// Default Component
 	if ( !$bp->current_component && $bp->displayed_user->id )
 		$bp->current_component = $bp->default_component;
 
 	// The default text for the members directory search box
-        $bp->default_search_strings[$bp->members->slug] = __( 'Search Members...', 'buddypress' );
+	$bp->default_search_strings[$bp->members->slug] = __( 'Search Members...', 'buddypress' );
 
 	do_action( 'bp_core_setup_globals' );
@@ -177,6 +193,4 @@
 
 /**
- * bp_core_get_table_prefix()
- *
  * Allow filtering of database prefix. Intended for use in multinetwork installations.
  *
@@ -191,6 +205,4 @@
 
 /**
- * bp_core_define_slugs()
- *
  * Define the slugs used for BuddyPress pages, based on the slugs of the WP pages used.
  * These can be overridden manually by defining these slugs in wp-config.php.
@@ -215,6 +227,4 @@
 
 /**
- * bp_core_get_page_meta()
- *
  * Fetches BP pages from the meta table, depending on setup
  *
@@ -231,6 +241,4 @@
 
 /**
- * bp_core_update_page_meta()
- *
  * Stores BP pages in the meta table, depending on setup
  *
@@ -285,7 +293,35 @@
 }
 
-/**
- * bp_core_admin_menu_init()
- *
+/** 
+ * Creates a default component slug from a WP page root_slug 
+ * 
+ * Since 1.3, BP components get their root_slug (the slug used immediately
+ * following the root domain) from the slug of a corresponding WP page.
+ * 
+ * E.g. if your BP installation at example.com has its members page at
+ * example.com/community/people, $bp->members->root_slug will be 'community/people'.
+ *
+ * By default, this function creates a shorter version of the root_slug for
+ * use elsewhere in the URL, by returning the content after the final '/'
+ * in the root_slug ('people' in the example above).
+ * 
+ * Filter on 'bp_core_component_slug_from_root_slug' to override this method
+ * in general, or define a specific component slug constant (e.g. BP_MEMBERS_SLUG)
+ * to override specific component slugs.
+ *  
+ * @package BuddyPress Core 
+ * @since 1.3 
+ * 
+ * @param str $root_slug The root slug, which comes from $bp->pages->[component]->slug 
+ * @return str $slug The short slug for use in the middle of URLs 
+ */ 
+function bp_core_component_slug_from_root_slug( $root_slug ) { 
+	$slug_chunks = explode( '/', $root_slug ); 
+ 	$slug        = array_pop( $slug_chunks );
+ 	
+ 	return apply_filters( 'bp_core_component_slug_from_root_slug', $slug, $root_slug ); 
+} 
+
+/**
  * Initializes the wp-admin area "BuddyPress" menus and sub menus.
  *
@@ -302,6 +338,4 @@
 
 /**
- * bp_core_add_admin_menu()
- *
  * Adds the "BuddyPress" admin submenu item to the Site Admin tab.
  *
@@ -334,26 +368,4 @@
 
 /**
- * bp_core_is_root_component()
- *
- * Checks to see if a component's URL should be in the root, not under a member page:
- * eg: http://domain.com/groups/the-group NOT http://domain.com/members/andy/groups/the-group
- *
- * @package BuddyPress Core
- * @return true if root component, else false.
- */
-function bp_core_is_root_component( $component_name ) {
-	global $bp;
-
-	foreach ( (array) $bp->pages as $key => $page ) {
-		if ( $key == $component_name || $page->slug == $component_name )
-			return true;
-	}
-
-	return false;
-}
-
-/**
- * bp_core_setup_nav()
- *
  * Sets up the profile navigation item if the Xprofile component is not installed.
  *
@@ -419,6 +431,4 @@
 
 /**
- * bp_core_action_directory_members()
- *
  * Listens to the $bp component and action variables to determine if the user is viewing the members
  * directory page. If they are, it will set up the directory and load the members directory template.
@@ -442,6 +452,4 @@
 
 /**
- * bp_core_action_set_spammer_status()
- *
  * When a site admin selects "Mark as Spammer/Not Spammer" from the admin menu
  * this action will fire and mark or unmark the user and their blogs as spam.
@@ -458,8 +466,8 @@
 
 	if ( 'admin' == $bp->current_component && ( 'mark-spammer' == $bp->current_action || 'unmark-spammer' == $bp->current_action ) ) {
-		/* Check the nonce */
+		// Check the nonce
 		check_admin_referer( 'mark-unmark-spammer' );
 
-		/* Get the functions file */
+		// Get the functions file
 		if ( is_multisite() )
 			require_once( ABSPATH . 'wp-admin/includes/ms.php' );
@@ -470,20 +478,20 @@
 			$is_spam = 0;
 
-		/* Get the blogs for the user */
+		// Get the blogs for the user
 		$blogs = get_blogs_of_user( $bp->displayed_user->id, true );
 
 		foreach ( (array) $blogs as $key => $details ) {
-			/* Do not mark the main or current root blog as spam */
+			// Do not mark the main or current root blog as spam
 			if ( 1 == $details->userblog_id || BP_ROOT_BLOG == $details->userblog_id )
 				continue;
 
-			/* Update the blog status */
+			// Update the blog status
 			update_blog_status( $details->userblog_id, 'spam', $is_spam );
 
-			/* Fire the standard WPMU hook */
+			// Fire the standard multisite hook
 			do_action( 'make_spam_blog', $details->userblog_id );
 		}
 
-		/* Finally, mark this user as a spammer */
+		// Finally, mark this user as a spammer
 		if ( is_multisite() )
 			$wpdb->update( $wpdb->users, array( 'spam' => $is_spam ), array( 'ID' => $bp->displayed_user->id ) );
@@ -496,11 +504,12 @@
 			bp_core_add_message( __( 'User removed as spammer.', 'buddypress' ) );
 
-		/* Hide this user's activity */
+		// Hide this user's activity
 		if ( $is_spam && function_exists( 'bp_activity_hide_user_activity' ) )
 			bp_activity_hide_user_activity( $bp->displayed_user->id );
 
-		// We need a special hook for is_spam so that components can delete data at spam time
+		// We need a special hook for is_spam so that components can
+		// delete data at spam time
 		if ( $is_spam )
-		        do_action( 'bp_make_spam_user', $bp->displayed_user->id );
+			do_action( 'bp_make_spam_user', $bp->displayed_user->id );
 
 		do_action( 'bp_core_action_set_spammer_status', $bp->displayed_user->id, $is_spam );
@@ -512,6 +521,4 @@
 
 /**
- * bp_core_action_delete_user()
- *
  * Allows a site admin to delete a user from the adminbar menu.
  *
@@ -526,5 +533,5 @@
 
 	if ( 'admin' == $bp->current_component && 'delete-user' == $bp->current_action ) {
-		/* Check the nonce */
+		// Check the nonce
 		check_admin_referer( 'delete-user' );
 
@@ -559,6 +566,4 @@
 
 /**
- * bp_core_get_users()
- *
  * Return an array of users IDs based on the parameters passed.
  *
@@ -587,8 +592,5 @@
 
 /**
- * bp_core_get_user_domain()
- *
- * Returns the domain for the passed user:
- * e.g. http://domain.com/members/andy/
+ * Returns the domain for the passed user: e.g. http://domain.com/members/andy/
  *
  * @package BuddyPress Core
@@ -605,5 +607,5 @@
 		$username = bp_core_get_username( $user_id, $user_nicename, $user_login );
 
-		/* If we are using a members slug, include it. */
+		// If we are using a members slug, include it.
 		if ( !defined( 'BP_ENABLE_ROOT_PROFILES' ) )
 			$domain = $bp->root_domain . '/' . $bp->members->slug . '/' . $username . '/';
@@ -611,5 +613,5 @@
 			$domain = $bp->root_domain . '/' . $username . '/';
 
-		/* Cache the link */
+		// Cache the link
 		if ( !empty( $domain ) )
 			wp_cache_set( 'bp_user_domain_' . $user_id, $domain, 'bp' );
@@ -620,6 +622,4 @@
 
 /**
- * bp_core_get_core_userdata()
- *
  * Fetch everything in the wp_users table for a user, without any usermeta.
  *
@@ -640,6 +640,4 @@
 
 /**
- * bp_core_get_root_domain()
- *
  * Returns the domain for the root blog.
  * eg: http://domain.com/ OR https://domain.com
@@ -661,6 +659,4 @@
 
 /**
- * bp_core_get_displayed_userid()
- *
  * Returns the user id for the user that is currently being displayed.
  * eg: http://andy.domain.com/ or http://domain.com/andy/
@@ -675,6 +671,4 @@
 
 /**
- * bp_core_new_nav_item()
- *
  * Adds a navigation item to the main navigation array used in BuddyPress themes.
  *
@@ -686,12 +680,12 @@
 
 	$defaults = array(
-		'name' => false, // Display name for the nav item
-		'slug' => false, // URL slug for the nav item
-		'item_css_id' => false, // The CSS ID to apply to the HTML of the nav item
-		'show_for_displayed_user' => true, // When viewing another user does this nav item show up?
-		'site_admin_only' => false, // Can only site admins see this nav item?
-		'position' => 99, // Index of where this nav item should be positioned
-		'screen_function' => false, // The name of the function to run when clicked
-		'default_subnav_slug' => false // The slug of the default subnav item to select when clicked
+		'name'                    => false, // Display name for the nav item
+		'slug'                    => false, // URL slug for the nav item
+		'item_css_id'             => false, // The CSS ID to apply to the HTML of the nav item
+		'show_for_displayed_user' => true,  // When viewing another user does this nav item show up?
+		'site_admin_only'         => false, // Can only site admins see this nav item?
+		'position'                => 99,    // Index of where this nav item should be positioned
+		'screen_function'         => false, // The name of the function to run when clicked
+		'default_subnav_slug'     => false  // The slug of the default subnav item to select when clicked
 	);
 
@@ -699,9 +693,9 @@
 	extract( $r, EXTR_SKIP );
 
-	/* If we don't have the required info we need, don't create this subnav item */
+	// If we don't have the required info we need, don't create this subnav item
 	if ( empty($name) || empty($slug) )
 		return false;
 
-	/* If this is for site admins only and the user is not one, don't create the subnav item */
+	// If this is for site admins only and the user is not one, don't create the subnav item
 	if ( $site_admin_only && !is_super_admin() )
 		return false;
@@ -711,11 +705,11 @@
 
 	$bp->bp_nav[$slug] = array(
-		'name' => $name,
-		'slug' => $slug,
-		'link' => $bp->loggedin_user->domain . $slug . '/',
-		'css_id' => $item_css_id,
+		'name'                    => $name,
+		'slug'                    => $slug,
+		'link'                    => $bp->loggedin_user->domain . $slug . '/',
+		'css_id'                  => $item_css_id,
 		'show_for_displayed_user' => $show_for_displayed_user,
-		'position' => $position,
-		'screen_function' => &$screen_function
+		'position'                => $position,
+		'screen_function'         => &$screen_function
 	);
 
@@ -732,5 +726,5 @@
  	 * default subnav function so we can display a directory or something else.
  	 */
-	if ( bp_core_is_root_component( $slug ) && !$bp->displayed_user->id )
+	if ( bp_is_root_component( $slug ) && !$bp->displayed_user->id )
 		return;
 
@@ -747,6 +741,4 @@
 
 /**
- * bp_core_new_nav_default()
- *
  * Modify the default subnav item to load when a top level nav item is clicked.
  *
@@ -758,7 +750,7 @@
 
 	$defaults = array(
-		'parent_slug' => false, // Slug of the parent
+		'parent_slug'     => false, // Slug of the parent
 		'screen_function' => false, // The name of the function to run when clicked
-		'subnav_slug' => false // The slug of the subnav item to select when clicked
+		'subnav_slug'     => false  // The slug of the subnav item to select when clicked
 	);
 
@@ -787,6 +779,4 @@
 
 /**
- * bp_core_sort_nav_items()
- *
  * We can only sort nav items by their position integer at a later point in time, once all
  * plugins have registered their navigation items.
@@ -817,10 +807,8 @@
 	$bp->bp_nav = &$temp;
 }
-add_action( 'wp_head', 'bp_core_sort_nav_items' );
+add_action( 'wp_head',    'bp_core_sort_nav_items' );
 add_action( 'admin_head', 'bp_core_sort_nav_items' );
 
 /**
- * bp_core_new_subnav_item()
- *
  * Adds a navigation item to the sub navigation array used in BuddyPress themes.
  *
@@ -832,13 +820,13 @@
 
 	$defaults = array(
-		'name' => false, // Display name for the nav item
-		'slug' => false, // URL slug for the nav item
-		'parent_slug' => false, // URL slug of the parent nav item
-		'parent_url' => false, // URL of the parent item
-		'item_css_id' => false, // The CSS ID to apply to the HTML of the nav item
-		'user_has_access' => true, // Can the logged in user see this nav item?
+		'name'            => false, // Display name for the nav item
+		'slug'            => false, // URL slug for the nav item
+		'parent_slug'     => false, // URL slug of the parent nav item
+		'parent_url'      => false, // URL of the parent item
+		'item_css_id'     => false, // The CSS ID to apply to the HTML of the nav item
+		'user_has_access' => true,  // Can the logged in user see this nav item?
 		'site_admin_only' => false, // Can only site admins see this nav item?
-		'position' => 90, // Index of where this nav item should be positioned
-		'screen_function' => false // The name of the function to run when clicked
+		'position'        => 90,    // Index of where this nav item should be positioned
+		'screen_function' => false  // The name of the function to run when clicked
 	);
 
@@ -846,9 +834,9 @@
 	extract( $r, EXTR_SKIP );
 
-	/* If we don't have the required info we need, don't create this subnav item */
-	if ( empty($name) || empty($slug) || empty($parent_slug) || empty($parent_url) || empty($screen_function) )
-		return false;
-
-	/* If this is for site admins only and the user is not one, don't create the subnav item */
+	// If we don't have the required info we need, don't create this subnav item
+	if ( empty( $name ) || empty( $slug ) || empty( $parent_slug ) || empty( $parent_url ) || empty( $screen_function ) )
+		return false;
+
+	// If this is for site admins only and the user is not one, don't create the subnav item
 	if ( $site_admin_only && !is_super_admin() )
 		return false;
@@ -858,13 +846,13 @@
 
 	$bp->bp_options_nav[$parent_slug][$slug] = array(
-		'name' => $name,
-		'link' => $parent_url . $slug . '/',
-		'slug' => $slug,
-		'css_id' => $item_css_id,
-		'position' => $position,
+		'name'            => $name,
+		'link'            => $parent_url . $slug . '/',
+		'slug'            => $slug,
+		'css_id'          => $item_css_id,
+		'position'        => $position,
 		'user_has_access' => $user_has_access,
 		'screen_function' => &$screen_function
 	);
-
+	
 	if ( ( $bp->current_action == $slug && $bp->current_component == $parent_slug ) && $user_has_access ) {
 		if ( !is_object( $screen_function[0] ) )
@@ -899,13 +887,11 @@
 		ksort( $temp );
 		$bp->bp_options_nav[$parent_slug] = &$temp;
-		unset($temp);
-	}
-}
-add_action( 'wp_head', 'bp_core_sort_subnav_items' );
+		unset( $temp );
+	}
+}
+add_action( 'wp_head',    'bp_core_sort_subnav_items' );
 add_action( 'admin_head', 'bp_core_sort_subnav_items' );
 
 /**
- * bp_core_remove_nav_item()
- *
  * Removes a navigation item from the sub navigation array used in BuddyPress themes.
  *
@@ -917,5 +903,5 @@
 	global $bp;
 
-	/* Unset subnav items for this nav item */
+	// Unset subnav items for this nav item
 	if ( is_array( $bp->bp_options_nav[$parent_id] ) ) {
 		foreach( (array)$bp->bp_options_nav[$parent_id] as $subnav_item ) {
@@ -935,6 +921,4 @@
 
 /**
- * bp_core_remove_subnav_item()
- *
  * Removes a navigation item from the sub navigation array used in BuddyPress themes.
  *
@@ -962,6 +946,4 @@
 
 /**
- * bp_core_reset_subnav_items()
- *
  * Clear the subnav items for a specific nav item.
  *
@@ -970,13 +952,11 @@
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
  */
-function bp_core_reset_subnav_items($parent_slug) {
-	global $bp;
-
-	unset($bp->bp_options_nav[$parent_slug]);
-}
-
-/**
- * bp_core_get_random_member()
- *
+function bp_core_reset_subnav_items( $parent_slug ) {
+	global $bp;
+
+	unset( $bp->bp_options_nav[$parent_slug] );
+}
+
+/**
  * Returns the user_id for a user based on their username.
  *
@@ -997,6 +977,4 @@
 
 /**
- * bp_core_get_userid()
- *
  * Returns the user_id for a user based on their username.
  *
@@ -1017,6 +995,4 @@
 
 /**
- * bp_core_get_userid_from_nicename()
- *
  * Returns the user_id for a user based on their user_nicename.
  *
@@ -1037,6 +1013,4 @@
 
 /**
- * bp_core_get_username()
- *
  * Returns the username for a user based on their user id.
  *
@@ -1076,5 +1050,5 @@
 	}
 
-	/* Add this to cache */
+	// Add this to cache
 	if ( !empty( $username ) )
 		wp_cache_set( 'bp_user_username_' . $user_id, $username, 'bp' );
@@ -1084,6 +1058,4 @@
 
 /**
- * bp_core_get_user_email()
- *
  * Returns the email address for the user based on user ID
  *
@@ -1105,6 +1077,4 @@
 
 /**
- * bp_core_get_userlink()
- *
  * Returns a HTML formatted link for a user with the user's full name as the link text.
  * eg: <a href="http://andy.domain.com/">Andy Peatling</a>
@@ -1146,6 +1116,4 @@
 
 /**
- * bp_core_get_user_displayname()
- *
  * Fetch the display name for a user. This will use the "Name" field in xprofile if it is installed.
  * Otherwise, it will fall back to the normal WP display_name, or user_nicename, depending on what has been set.
@@ -1203,11 +1171,9 @@
 }
 add_filter( 'bp_core_get_user_displayname', 'strip_tags', 1 );
-add_filter( 'bp_core_get_user_displayname', 'trim' );
-add_filter( 'bp_core_get_user_displayname', 'stripslashes' );
-
-
-/**
- * bp_core_get_userlink_by_email()
- *
+add_filter( 'bp_core_get_user_displayname', 'trim'          );
+add_filter( 'bp_core_get_user_displayname', 'stripslashes'  );
+
+
+/**
  * Returns the user link for the user based on user email address
  *
@@ -1224,6 +1190,4 @@
 
 /**
- * bp_core_get_userlink_by_username()
- *
  * Returns the user link for the user based on user's username
  *
@@ -1241,6 +1205,4 @@
 
 /**
- * bp_core_get_total_member_count()
- *
  * Returns the total number of members for the installation.
  *
@@ -1261,6 +1223,4 @@
 
 /**
- * bp_core_is_user_spammer()
- *
  * Checks if the user has been marked as a spammer.
  *
@@ -1281,6 +1241,4 @@
 
 /**
- * bp_core_is_user_deleted()
- *
  * Checks if the user has been marked as deleted.
  *
@@ -1296,6 +1254,4 @@
 
 /**
- * bp_core_current_time()
- *
  * Get the current GMT time to save into the DB
  *
@@ -1311,6 +1267,4 @@
 
 /**
- * bp_core_add_message()
- *
  * Adds a feedback (error/success) message to the WP cookie so it can be displayed after the page reloads.
  *
@@ -1323,5 +1277,5 @@
 		$type = 'success';
 
-	/* Send the values to the cookie for page reload display */
+	// Send the values to the cookie for page reload display
 	@setcookie( 'bp-message', $message, time()+60*60*24, COOKIEPATH );
 	@setcookie( 'bp-message-type', $type, time()+60*60*24, COOKIEPATH );
@@ -1331,16 +1285,15 @@
 	 * without a page reload
 	 */
-	$bp->template_message = $message;
+	$bp->template_message      = $message;
 	$bp->template_message_type = $type;
 }
 
 /**
- * bp_core_setup_message()
- *
- * Checks if there is a feedback message in the WP cookie, if so, adds a "template_notices" action
- * so that the message can be parsed into the template and displayed to the user.
- *
- * After the message is displayed, it removes the message vars from the cookie so that the message
- * is not shown to the user multiple times.
+ * Checks if there is a feedback message in the WP cookie, if so, adds a
+ * "template_notices" action so that the message can be parsed into the template
+ * and displayed to the user.
+ *
+ * After the message is displayed, it removes the message vars from the cookie
+ * so that the message is not shown to the user multiple times.
  *
  * @package BuddyPress Core
@@ -1366,6 +1319,4 @@
 
 /**
- * bp_core_render_message()
- *
  * Renders a feedback message (either error or success message) to the theme template.
  * The hook action 'template_notices' is used to call this function, it is not called directly.
@@ -1378,10 +1329,12 @@
 
 	if ( isset( $bp->template_message ) && $bp->template_message ) {
-		$type = ( 'success' == $bp->template_message_type ) ? 'updated' : 'error';
-	?>
+		$type = ( 'success' == $bp->template_message_type ) ? 'updated' : 'error'; ?>
+
 		<div id="message" class="<?php echo $type; ?>">
 			<p><?php echo stripslashes( esc_attr( $bp->template_message ) ); ?></p>
 		</div>
+
 	<?php
+
 		do_action( 'bp_core_render_message' );
 	}
@@ -1389,6 +1342,4 @@
 
 /**
- * bp_core_time_since()
- *
  * Based on function created by Dunstan Orchard - http://1976design.com
  *
@@ -1424,12 +1375,15 @@
 	}
 
-	/* $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' );
@@ -1442,21 +1396,21 @@
 	 */
 
-	/* Step one: the first chunk */
+	// 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;
 	}
 
-        // If $i iterates all the way to $j, then the event happened 0 seconds ago
-        if ( !isset( $chunks[$i] ) )
+	// If $i iterates all the way to $j, then the event happened 0 seconds ago
+	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];
@@ -1469,5 +1423,5 @@
 	}
 
-	if ( !(int)trim($output) )
+	if ( !(int)trim( $output ) )
 		$output = '0 ' . __( 'seconds', 'buddypress' );
 
@@ -1477,6 +1431,4 @@
 
 /**
- * bp_core_record_activity()
- *
  * Record user activity to the database. Many functions use a "last active" feature to
  * show the length of time since the user was last active.
@@ -1501,5 +1453,5 @@
 	$current_time = bp_core_current_time();
 
-	if ( '' == $activity || strtotime( $current_time ) >= strtotime( '+5 minutes', $activity ) )
+	if ( empty( $activity ) || strtotime( $current_time ) >= strtotime( '+5 minutes', $activity ) )
 		update_user_meta( $bp->loggedin_user->id, 'last_activity', $current_time );
 }
@@ -1508,6 +1460,4 @@
 
 /**
- * bp_core_get_last_activity()
- *
  * Formats last activity based on time since date given.
  *
@@ -1519,9 +1469,8 @@
  */
 function bp_core_get_last_activity( $last_activity_date, $string ) {
-	if ( !$last_activity_date || empty( $last_activity_date ) ) {
+	if ( !$last_activity_date || empty( $last_activity_date ) )
 		$last_active = __( 'not recently active', 'buddypress' );
-	} else {
+	else
 		$last_active = sprintf( $string, bp_core_time_since( $last_activity_date ) );
-	}
 
 	return apply_filters( 'bp_core_get_last_activity', $last_active, $last_activity_date, $string );
@@ -1529,5 +1478,5 @@
 
 function bp_core_number_format( $number, $decimals = false ) {
-	/* Check we actually have a number first. */
+	// Check we actually have a number first.
 	if ( empty( $number ) )
 		return $number;
@@ -1537,6 +1486,4 @@
 
 /**
- * bp_core_get_all_posts_for_user()
- *
  * Fetch every post that is authored by the given user for the current blog.
  *
@@ -1546,8 +1493,8 @@
  * @return array of post ids.
  */
-function bp_core_get_all_posts_for_user( $user_id = null ) {
+function bp_core_get_all_posts_for_user( $user_id = 0 ) {
 	global $bp, $wpdb;
 
-	if ( !$user_id )
+	if ( empty( $user_id ) )
 		$user_id = $bp->displayed_user->id;
 
@@ -1556,6 +1503,4 @@
 
 /**
- * bp_core_get_site_path()
- *
  * Get the path of of the current site.
  *
@@ -1577,5 +1522,5 @@
 			$site_path = '/';
 		else {
-			/* Unset the first three segments (http(s)://domain.com part) */
+			// Unset the first three segments (http(s)://domain.com part)
 			unset( $site_path[0] );
 			unset( $site_path[1] );
@@ -1593,6 +1538,4 @@
 
 /**
- * bp_core_redirect()
- *
  * Performs a status safe wp_redirect() that is compatible with bp_catch_uri()
  *
@@ -1614,6 +1557,4 @@
 
 /**
- * bp_core_referrer()
- *
  * Returns the referrer URL without the http(s)://
  *
@@ -1628,6 +1569,4 @@
 
 /**
- * bp_core_add_illegal_names()
- *
  * Adds illegal names to WP so that root components will not conflict with
  * blog names on a subdirectory installation.
@@ -1640,6 +1579,4 @@
 
 /**
- * bp_core_delete_account()
- *
  * Allows a user to completely remove their account from the system
  *
@@ -1657,13 +1594,13 @@
 		$user_id = $bp->loggedin_user->id;
 
-	/* Make sure account deletion is not disabled */
+	// Make sure account deletion is not disabled
 	if ( !empty( $bp->site_options['bp-disable-account-deletion'] ) && !$bp->loggedin_user->is_super_admin )
 		return false;
 
-	/* Site admins cannot be deleted */
+	// Site admins cannot be deleted
 	if ( is_super_admin( bp_core_get_username( $user_id ) ) )
 		return false;
 
-	/* Specifically handle multi-site environment */
+	// Specifically handle multi-site environment
 	if ( is_multisite() ) {
 		if ( $wp_version >= '3.0' )
@@ -1676,5 +1613,5 @@
 		return wpmu_delete_user( $user_id );
 
-	/* Single site user deletion */
+	// Single site user deletion
 	} else {
 		require_once( ABSPATH . '/wp-admin/includes/user.php' );
@@ -1684,6 +1621,4 @@
 
 /**
- * bp_core_search_site()
- *
  * A javascript free implementation of the search functions in BuddyPress
  *
@@ -1712,11 +1647,14 @@
 				$slug = bp_is_active( 'blogs' )  ? $bp->blogs->slug  : '';
 				break;
+
 			case 'forums':
 				$slug = bp_is_active( 'forums' ) ? $bp->forums->slug : '';
 				$query_string = '/?fs=';
 				break;
+
 			case 'groups':
 				$slug = bp_is_active( 'groups' ) ? $bp->groups->slug : '';
 				break;
+
 			case 'members':
 			default:
@@ -1735,8 +1673,5 @@
 add_action( 'init', 'bp_core_action_search_site', 5 );
 
-
-/**
- * bp_core_ucfirst()
- *
+/**
  * Localization safe ucfirst() support.
  *
@@ -1752,8 +1687,5 @@
 }
 
-
-/**
- * bp_core_strip_username_spaces()
- *
+/**
  * Strips spaces from usernames that are created using add_user() and wp_insert_user()
  *
@@ -1761,8 +1693,8 @@
  */
 function bp_core_strip_username_spaces( $username ) {
-        // Don't alter the user_login of existing users, as it causes user_nicename problems.
-        // See http://trac.buddypress.org/ticket/2642
-        if ( username_exists( $username ) && ( !defined( 'BP_ENABLE_USER_COMPATIBILITY_MODE' ) || !BP_ENABLE_USER_COMPATIBILITY_MODE ) )
-                return $username;
+	// Don't alter the user_login of existing users, as it causes user_nicename problems.
+	// See http://trac.buddypress.org/ticket/2642
+	if ( username_exists( $username ) && ( !defined( 'BP_ENABLE_USER_COMPATIBILITY_MODE' ) || !BP_ENABLE_USER_COMPATIBILITY_MODE ) )
+		return $username;
 
 	return str_replace( ' ', '-', $username );
@@ -1770,7 +1702,5 @@
 add_action( 'pre_user_login', 'bp_core_strip_username_spaces' );
 
-
-/**
- * bp_core_clear_cache()
+/**
  * REQUIRES WP-SUPER-CACHE
  *
@@ -1791,6 +1721,4 @@
 
 /**
- * bp_core_print_generation_time()
- *
  * Prints the generation time in the footer of the site.
  *
@@ -1807,6 +1735,4 @@
 
 /**
- * bp_core_add_admin_menu_page()
- *
  * A better version of add_admin_menu_page() that allows positioning of menus.
  *
@@ -1854,6 +1780,4 @@
 
 /**
- * bp_core_boot_spammer()
- *
  * When a user logs in, check if they have been marked as a spammer. If yes then simply
  * redirect them to the home page and stop them from logging in.
@@ -1870,5 +1794,5 @@
 
 	if ( !$user = get_userdatabylogin( $username ) )
-	        return false;
+		return false;
 
 	if ( ( is_multisite() && (int)$user->spam ) || 1 == (int)$user->user_status )
@@ -1880,6 +1804,4 @@
 
 /**
- * bp_core_remove_data()
- *
  * Deletes usermeta for the user when the user is deleted.
  *
@@ -1889,17 +1811,15 @@
  */
 function bp_core_remove_data( $user_id ) {
-	/* Remove usermeta */
+	// Remove usermeta
 	delete_user_meta( $user_id, 'last_activity' );
 
-	/* Flush the cache to remove the user from all cached objects */
+	// Flush the cache to remove the user from all cached objects
 	wp_cache_flush();
 }
-add_action( 'wpmu_delete_user', 'bp_core_remove_data' );
-add_action( 'delete_user', 'bp_core_remove_data' );
+add_action( 'wpmu_delete_user',  'bp_core_remove_data' );
+add_action( 'delete_user',       'bp_core_remove_data' );
 add_action( 'bp_make_spam_user', 'bp_core_remove_data' );
 
 /**
- * bp_load_buddypress_textdomain()
- *
  * Load the buddypress translation file for current language
  *
@@ -1922,5 +1842,5 @@
 
 function bp_core_add_ajax_hook() {
-	/* Theme only, we already have the wp_ajax_ hook firing in wp-admin */
+	// Theme only, we already have the wp_ajax_ hook firing in wp-admin
 	if ( !defined( 'WP_ADMIN' ) && isset( $_REQUEST['action'] ) )
 		do_action( 'wp_ajax_' . $_REQUEST['action'] );
@@ -1929,6 +1849,4 @@
 
 /**
- * bp_core_update_message()
- *
  * Add an extra update message to the update plugin notification.
  *
@@ -1941,6 +1859,4 @@
 
 /**
- * bp_core_activation_notice()
- *
  * When BuddyPress is activated we must make sure that mod_rewrite is enabled.
  * We must also make sure a BuddyPress compatible theme is enabled. This function
@@ -1964,16 +1880,22 @@
 
 	if ( empty( $wp_rewrite->permalink_structure ) ) { ?>
+
 		<div id="message" class="updated fade">
 			<p><?php printf( __( '<strong>BuddyPress is almost ready</strong>. You must <a href="%s">update your permalink structure</a> to something other than the default for it to work.', 'buddypress' ), admin_url( 'options-permalink.php' ) ) ?></p>
 		</div><?php
+
 	} else {
-		/* Get current theme info */
+		// Get current theme info
 		$ct = current_theme_info();
 
-		/* The best way to remove this notice is to add a "buddypress" tag to your active theme's CSS header. */
+		// The best way to remove this notice is to add a "buddypress" tag to
+		// your active theme's CSS header.
 		if ( !defined( 'BP_SILENCE_THEME_NOTICE' ) && !in_array( 'buddypress', (array)$ct->tags ) ) { ?>
+
 			<div id="message" class="updated fade">
 				<p style="line-height: 150%"><?php printf( __( "<strong>BuddyPress is ready</strong>. You'll need to <a href='%s'>activate a BuddyPress compatible theme</a> to take advantage of all of the features. We've bundled a default theme, but you can always <a href='%s'>install some other compatible themes</a> or <a href='%s'>update your existing WordPress theme</a>.", 'buddypress' ), admin_url( 'themes.php' ), admin_url( 'theme-install.php?type=tag&s=buddypress&tab=search' ), admin_url( 'plugin-install.php?type=term&tab=search&s=%22bp-template-pack%22' ) ) ?></p>
-			</div><?php
+			</div>
+
+		<?php
 		}
 	}
@@ -1982,6 +1904,4 @@
 
 /**
- * bp_core_activate_site_options()
- *
  * When switching from single to multisite we need to copy blog options to
  * site options.
@@ -2019,6 +1939,4 @@
 
 /**
- * bp_include()
- *
  * Allow plugins to include their files ahead of core filters
  */
@@ -2029,6 +1947,4 @@
 
 /**
- * bp_setup_root_components()
- *
  * Allow core components and dependent plugins to set root components
  */
@@ -2039,6 +1955,4 @@
 
 /**
- * bp_setup_globals()
- *
  * Allow core components and dependent plugins to set globals
  */
@@ -2049,6 +1963,4 @@
 
 /**
- * bp_setup_nav()
- *
  * Allow core components and dependent plugins to set their nav
  */
@@ -2059,6 +1971,4 @@
 
 /**
- * bp_setup_widgets()
- *
  * Allow core components and dependent plugins to register widgets
  */
@@ -2069,6 +1979,4 @@
 
 /**
- * bp_init()
- *
  * Allow components to initialize themselves cleanly
  */
@@ -2087,6 +1995,4 @@
 
 /**
- * bp_core_add_global_group()
- *
  * Add's 'bp' to global group of network wide cachable objects
  *
@@ -2102,6 +2008,4 @@
 
 /**
- * bp_core_clear_user_object_cache()
- *
  * Clears all cached objects for a user, or a user is part of.
  *
@@ -2113,60 +2017,6 @@
 
 // List actions to clear super cached pages on, if super cache is installed
-add_action( 'wp_login', 'bp_core_clear_cache' );
+add_action( 'wp_login',              'bp_core_clear_cache' );
 add_action( 'bp_core_render_notice', 'bp_core_clear_cache' );
 
-
-/* DEPRECATED FUNCTIONS ****/
-
-/**
- * bp_core_add_root_component()
- *
- * This function originally let plugins add support for pages in the root of the install.
- * These pages are now handled by actual WordPress pages so this function is deprecated.
- * It now simply facilitates backwards compatibility by adding a WP page if the plugin has not been
- * updated to do so.
- *
- * @deprecated 1.3
- * @deprecated Use wp_insert_post() to create a page
- * @package BuddyPress Core
- * @param $slug str The slug of the component
- * @global $bp BuddyPress global settings
- */
-function bp_core_add_root_component( $slug ) {
-	global $bp, $bp_pages;
-
-	_deprecated_function( __FUNCTION__, '1.3', 'wp_insert_post()' );
-	if ( empty( $bp_pages ) )
-		$bp_pages = bp_core_get_page_names();
-
-	$match = false;
-
-	/* Check if the slug is registered in the $bp->pages global */
-	foreach ( (array)$bp_pages as $key => $page ) {
-		if ( $key == $slug || $page->slug == $slug )
-			$match = true;
-	}
-
-	/* If there was no match, add a page for this root component */
-	if ( empty( $match ) ) {
-		$bp->add_root[] = $slug;
-		add_action( 'init', 'bp_core_create_root_component_page' );
-	}
-}
-
-function bp_core_create_root_component_page() {
-	global $bp;
-
-	$new_page_ids = array();
-
-	foreach ( (array)$bp->add_root as $slug )
-		$new_page_ids[$slug] = wp_insert_post( array( 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_title' => ucwords( $slug ), 'post_status' => 'publish', 'post_type' => 'page' ) );
-
-	$page_ids = bp_core_get_page_meta();
-
-	$page_ids = (array) $page_ids;
-	$page_ids = array_merge( (array) $new_page_ids, (array) $page_ids );
-
-	bp_core_update_page_meta( $page_ids );
-}
 ?>
Index: /trunk/bp-core/admin/bp-core-admin.php
===================================================================
--- /trunk/bp-core/admin/bp-core-admin.php	(revision 3727)
+++ /trunk/bp-core/admin/bp-core-admin.php	(revision 3728)
@@ -6,5 +6,5 @@
 		<div id="bp-admin-header">
 			<h3><?php _e( 'BuddyPress', 'buddypress' ) ?></h3>
-			<h2><?php _e( 'Dashboard', 'buddypress' ) ?></h2>
+			<h2><?php _e( 'Dashboard',  'buddypress' ) ?></h2>
 		</div>
 
@@ -18,4 +18,5 @@
 
 	</div>
+
 <?php
 }
@@ -25,7 +26,5 @@
 
 	$ud = get_userdata( $bp->loggedin_user->id );
-?>
-
-	<?php
+
 	if ( isset( $_POST['bp-admin-submit'] ) && isset( $_POST['bp-admin'] ) ) {
 		if ( !check_admin_referer('bp-admin') )
@@ -52,7 +51,9 @@
 
 		<?php if ( isset( $_POST['bp-admin'] ) ) : ?>
+
 			<div id="message" class="updated fade">
 				<p><?php _e( 'Settings Saved', 'buddypress' ) ?></p>
 			</div>
+
 		<?php endif; ?>
 
@@ -60,68 +61,79 @@
 
 			<table class="form-table">
-			<tbody>
-				<?php if ( bp_is_active( 'xprofile' ) ) : ?>
-				<tr>
-					<th scope="row"><?php _e( 'Base profile group name', 'buddypress' ) ?>:</th>
-					<td>
-						<input name="bp-admin[bp-xprofile-base-group-name]" id="bp-xprofile-base-group-name" value="<?php echo esc_attr( stripslashes( get_site_option( 'bp-xprofile-base-group-name' ) ) ) ?>" />
-					</td>
-				</tr>
-				<tr>
-					<th scope="row"><?php _e( 'Full Name field name', 'buddypress' ) ?>:</th>
-					<td>
-						<input name="bp-admin[bp-xprofile-fullname-field-name]" id="bp-xprofile-fullname-field-name" value="<?php echo esc_attr( stripslashes( get_site_option( 'bp-xprofile-fullname-field-name' ) ) ) ?>" />
-					</td>
-				</tr>
-				<tr>
-					<th scope="row"><?php _e( 'Disable BuddyPress to WordPress profile syncing?', 'buddypress' ) ?>:</th>
-					<td>
-						<input type="radio" name="bp-admin[bp-disable-profile-sync]"<?php if ( (int)get_site_option( 'bp-disable-profile-sync' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-profile-sync" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
-						<input type="radio" name="bp-admin[bp-disable-profile-sync]"<?php if ( !(int)get_site_option( 'bp-disable-profile-sync' ) || '' == get_site_option( 'bp-disable-profile-sync' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-profile-sync" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
-					</td>
-				</tr>
-				<?php endif; ?>
-				<tr>
-					<th scope="row"><?php _e( 'Hide admin bar for logged out users?', 'buddypress' ) ?>:</th>
-					<td>
-						<input type="radio" name="bp-admin[hide-loggedout-adminbar]"<?php if ( (int)get_site_option( 'hide-loggedout-adminbar' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-hide-loggedout-adminbar-yes" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
-						<input type="radio" name="bp-admin[hide-loggedout-adminbar]"<?php if ( !(int)get_site_option( 'hide-loggedout-adminbar' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-hide-loggedout-adminbar-no" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
-					</td>
-				</tr>
-				<tr>
-					<th scope="row"><?php _e( 'Disable avatar uploads? (Gravatars will still work)', 'buddypress' ) ?>:</th>
-					<td>
-						<input type="radio" name="bp-admin[bp-disable-avatar-uploads]"<?php if ( (int)get_site_option( 'bp-disable-avatar-uploads' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-disable-avatar-uploads-yes" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
-						<input type="radio" name="bp-admin[bp-disable-avatar-uploads]"<?php if ( !(int)get_site_option( 'bp-disable-avatar-uploads' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-disable-avatar-uploads-no" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
-					</td>
-				</tr>
-				<tr>
-					<th scope="row"><?php _e( 'Disable user account deletion?', 'buddypress' ) ?>:</th>
-					<td>
-						<input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( (int)get_site_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
-						<input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( !(int)get_site_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
-					</td>
-				</tr>
-				<?php if ( function_exists( 'bp_forums_setup') ) : ?>
-				<tr>
-					<th scope="row"><?php _e( 'Disable global forum directory?', 'buddypress' ) ?>:</th>
-					<td>
-						<input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( (int)get_site_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
-						<input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( !(int)get_site_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
-					</td>
-				</tr>
-				<?php endif; ?>
-				<?php if ( bp_is_active( 'activity' ) ) : ?>
-				<tr>
-					<th scope="row"><?php _e( 'Disable activity stream commenting on blog and forum posts?', 'buddypress' ) ?>:</th>
-					<td>
-						<input type="radio" name="bp-admin[bp-disable-blogforum-comments]"<?php if ( (int)get_site_option( 'bp-disable-blogforum-comments' ) || false === get_site_option( 'bp-disable-blogforum-comments' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-blogforum-comments" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
-						<input type="radio" name="bp-admin[bp-disable-blogforum-comments]"<?php if ( !(int)get_site_option( 'bp-disable-blogforum-comments' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-blogforum-comments" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
-					</td>
-				</tr>
-				<?php endif; ?>
-
-				<?php do_action( 'bp_core_admin_screen_fields' ) ?>
-			</tbody>
+				<tbody>
+
+					<?php if ( bp_is_active( 'xprofile' ) ) : ?>
+
+						<tr>
+							<th scope="row"><?php _e( 'Base profile group name', 'buddypress' ) ?>:</th>
+							<td>
+								<input name="bp-admin[bp-xprofile-base-group-name]" id="bp-xprofile-base-group-name" value="<?php echo esc_attr( stripslashes( get_site_option( 'bp-xprofile-base-group-name' ) ) ) ?>" />
+							</td>
+						</tr>
+						<tr>
+							<th scope="row"><?php _e( 'Full Name field name', 'buddypress' ) ?>:</th>
+							<td>
+								<input name="bp-admin[bp-xprofile-fullname-field-name]" id="bp-xprofile-fullname-field-name" value="<?php echo esc_attr( stripslashes( get_site_option( 'bp-xprofile-fullname-field-name' ) ) ) ?>" />
+							</td>
+						</tr>
+						<tr>
+							<th scope="row"><?php _e( 'Disable BuddyPress to WordPress profile syncing?', 'buddypress' ) ?>:</th>
+							<td>
+								<input type="radio" name="bp-admin[bp-disable-profile-sync]"<?php if ( (int)get_site_option( 'bp-disable-profile-sync' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-profile-sync" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
+								<input type="radio" name="bp-admin[bp-disable-profile-sync]"<?php if ( !(int)get_site_option( 'bp-disable-profile-sync' ) || '' == get_site_option( 'bp-disable-profile-sync' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-profile-sync" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
+							</td>
+						</tr>
+
+					<?php endif; ?>
+
+					<tr>
+						<th scope="row"><?php _e( 'Hide admin bar for logged out users?', 'buddypress' ) ?>:</th>
+						<td>
+							<input type="radio" name="bp-admin[hide-loggedout-adminbar]"<?php if ( (int)get_site_option( 'hide-loggedout-adminbar' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-hide-loggedout-adminbar-yes" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
+							<input type="radio" name="bp-admin[hide-loggedout-adminbar]"<?php if ( !(int)get_site_option( 'hide-loggedout-adminbar' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-hide-loggedout-adminbar-no" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
+						</td>
+					</tr>
+					<tr>
+						<th scope="row"><?php _e( 'Disable avatar uploads? (Gravatars will still work)', 'buddypress' ) ?>:</th>
+						<td>
+							<input type="radio" name="bp-admin[bp-disable-avatar-uploads]"<?php if ( (int)get_site_option( 'bp-disable-avatar-uploads' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-disable-avatar-uploads-yes" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
+							<input type="radio" name="bp-admin[bp-disable-avatar-uploads]"<?php if ( !(int)get_site_option( 'bp-disable-avatar-uploads' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-disable-avatar-uploads-no" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
+						</td>
+					</tr>
+					<tr>
+						<th scope="row"><?php _e( 'Disable user account deletion?', 'buddypress' ) ?>:</th>
+						<td>
+							<input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( (int)get_site_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
+							<input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( !(int)get_site_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
+						</td>
+					</tr>
+
+					<?php if ( function_exists( 'bp_forums_setup') ) : ?>
+
+						<tr>
+							<th scope="row"><?php _e( 'Disable global forum directory?', 'buddypress' ) ?>:</th>
+							<td>
+								<input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( (int)get_site_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
+								<input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( !(int)get_site_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
+							</td>
+						</tr>
+
+					<?php endif; ?>
+
+					<?php if ( bp_is_active( 'activity' ) ) : ?>
+
+						<tr>
+							<th scope="row"><?php _e( 'Disable activity stream commenting on blog and forum posts?', 'buddypress' ) ?>:</th>
+							<td>
+								<input type="radio" name="bp-admin[bp-disable-blogforum-comments]"<?php if ( (int)get_site_option( 'bp-disable-blogforum-comments' ) || false === get_site_option( 'bp-disable-blogforum-comments' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-blogforum-comments" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
+								<input type="radio" name="bp-admin[bp-disable-blogforum-comments]"<?php if ( !(int)get_site_option( 'bp-disable-blogforum-comments' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-blogforum-comments" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
+							</td>
+						</tr>
+
+					<?php endif; ?>
+
+					<?php do_action( 'bp_core_admin_screen_fields' ) ?>
+
+				</tbody>
 			</table>
 
@@ -143,7 +155,5 @@
 function bp_core_admin_component_setup() {
 	global $wpdb, $bp;
-?>
-
-	<?php
+
 	if ( isset( $_POST['bp-admin-component-submit'] ) && isset( $_POST['bp_components'] ) ) {
 		if ( !check_admin_referer('bp-admin-component-setup') )
@@ -156,6 +166,5 @@
 		}
 		update_site_option( 'bp-deactivated-components', $disabled );
-	}
-	?>
+	} ?>
 
 	<div class="wrap">
@@ -164,7 +173,9 @@
 
 		<?php if ( isset( $_POST['bp-admin-component-submit'] ) ) : ?>
+
 			<div id="message" class="updated fade">
 				<p><?php _e( 'Settings Saved', 'buddypress' ) ?></p>
 			</div>
+
 		<?php endif; ?>
 
@@ -176,71 +187,95 @@
 
 			<table class="form-table" style="width: 80%">
-			<tbody>
-				<?php if ( file_exists( BP_PLUGIN_DIR . '/bp-activity.php') ) : ?>
-				<tr>
-					<td><h3><?php _e( 'Activity Streams', 'buddypress' ) ?></h3><p><?php _e( 'Allow users to post activity updates and track all activity across the entire site.', 'buddypress' ) ?></p></td>
-					<td>
-						<input type="radio" name="bp_components[bp-activity.php]" value="1"<?php if ( !isset( $disabled_components['bp-activity.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> &nbsp;
-						<input type="radio" name="bp_components[bp-activity.php]" value="0"<?php if ( isset( $disabled_components['bp-activity.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
-					</td>
-				</tr>
-				<?php endif; ?>
-				<?php if ( file_exists( BP_PLUGIN_DIR . '/bp-blogs.php') && is_multisite() ) : ?>
-				<tr>
-					<td><h3><?php _e( 'Blog Tracking', 'buddypress' ) ?></h3><p><?php _e( 'Tracks blogs, blog posts and blogs comments for a user across a WPMU installation.', 'buddypress' ) ?></p></td>
-					<td>
-						<input type="radio" name="bp_components[bp-blogs.php]" value="1"<?php if ( !isset( $disabled_components['bp-blogs.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?>  &nbsp;
-						<input type="radio" name="bp_components[bp-blogs.php]" value="0"<?php if ( isset( $disabled_components['bp-blogs.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
-					</td>
-				</tr>
-				<?php else: ?>
-					<input type="hidden" name="bp_components[bp-blogs.php]" value="0" />
-				<?php endif; ?>
-				<?php if ( file_exists( BP_PLUGIN_DIR . '/bp-forums.php') ) : ?>
-				<tr>
-					<td><h3><?php _e( 'bbPress Forums', 'buddypress' ) ?></h3><p><?php _e( 'Activates bbPress forum support within BuddyPress groups or any other custom component.', 'buddypress' ) ?></p></td>
-					<td>
-						<input type="radio" name="bp_components[bp-forums.php]" value="1"<?php if ( !isset( $disabled_components['bp-forums.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?>  &nbsp;
-						<input type="radio" name="bp_components[bp-forums.php]" value="0"<?php if ( isset( $disabled_components['bp-forums.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
-					</td>
-				</tr>
-				<?php endif; ?>
-				<?php if ( file_exists( BP_PLUGIN_DIR . '/bp-friends.php') ) : ?>
-				<tr>
-					<td><h3><?php _e( 'Friends', 'buddypress' ) ?></h3><p><?php _e( 'Allows the creation of friend connections between users.', 'buddypress' ) ?></p></td>
-					<td>
-						<input type="radio" name="bp_components[bp-friends.php]" value="1"<?php if ( !isset( $disabled_components['bp-friends.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?>  &nbsp;
-						<input type="radio" name="bp_components[bp-friends.php]" value="0"<?php if ( isset( $disabled_components['bp-friends.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
-					</td>
-				</tr>
-				<?php endif; ?>
-				<?php if ( file_exists( BP_PLUGIN_DIR . '/bp-groups.php') ) : ?>
-				<tr>
-					<td><h3><?php _e( 'Groups', 'buddypress' ) ?></h3><p><?php _e( 'Let users create, join and participate in groups.', 'buddypress' ) ?></p></td>
-					<td>
-						<input type="radio" name="bp_components[bp-groups.php]" value="1"<?php if ( !isset( $disabled_components['bp-groups.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?>  &nbsp;
-						<input type="radio" name="bp_components[bp-groups.php]" value="0"<?php if ( isset( $disabled_components['bp-groups.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
-					</td>
-				</tr>
-				<?php endif; ?>
-				<?php if ( file_exists( BP_PLUGIN_DIR . '/bp-messages.php') ) : ?>
-				<tr>
-					<td><h3><?php _e( 'Private Messaging', 'buddypress' ) ?></h3><p><?php _e( 'Let users send private messages to one another. Site admins can also send site-wide notices.', 'buddypress' ) ?></p></td>
-					<td>
-						<input type="radio" name="bp_components[bp-messages.php]" value="1"<?php if ( !isset( $disabled_components['bp-messages.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?>  &nbsp;
-						<input type="radio" name="bp_components[bp-messages.php]" value="0"<?php if ( isset( $disabled_components['bp-messages.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
-					</td>
-				</tr>
-				<?php endif; ?>
-				<?php if ( file_exists( BP_PLUGIN_DIR . '/bp-xprofile.php') ) : ?>
-				<tr>
-					<td><h3><?php _e( 'Extended Profiles', 'buddypress' ) ?></h3><p><?php _e( 'Activates customizable profiles and avatars for site users.', 'buddypress' ) ?></p></td>
-					<td width="45%">
-						<input type="radio" name="bp_components[bp-xprofile.php]" value="1"<?php if ( !isset( $disabled_components['bp-xprofile.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?>  &nbsp;
-						<input type="radio" name="bp_components[bp-xprofile.php]" value="0"<?php if ( isset( $disabled_components['bp-xprofile.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
-					</td>
-				</tr>
-				<?php endif; ?>
-			</tbody>
+				<tbody>
+
+					<?php if ( file_exists( BP_PLUGIN_DIR . '/bp-activity.php') ) : ?>
+
+						<tr>
+							<td><h3><?php _e( 'Activity Streams', 'buddypress' ) ?></h3><p><?php _e( 'Allow users to post activity updates and track all activity across the entire site.', 'buddypress' ) ?></p></td>
+							<td>
+								<input type="radio" name="bp_components[bp-activity.php]" value="1"<?php if ( !isset( $disabled_components['bp-activity.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> &nbsp;
+								<input type="radio" name="bp_components[bp-activity.php]" value="0"<?php if ( isset( $disabled_components['bp-activity.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
+							</td>
+						</tr>
+
+					<?php endif; ?>
+
+					<?php if ( file_exists( BP_PLUGIN_DIR . '/bp-blogs.php') && is_multisite() ) : ?>
+
+						<tr>
+							<td><h3><?php _e( 'Blog Tracking', 'buddypress' ) ?></h3><p><?php _e( 'Tracks blogs, blog posts and blogs comments for a user across a WPMU installation.', 'buddypress' ) ?></p></td>
+							<td>
+								<input type="radio" name="bp_components[bp-blogs.php]" value="1"<?php if ( !isset( $disabled_components['bp-blogs.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?>  &nbsp;
+								<input type="radio" name="bp_components[bp-blogs.php]" value="0"<?php if ( isset( $disabled_components['bp-blogs.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
+							</td>
+						</tr>
+
+					<?php else: ?>
+
+						<input type="hidden" name="bp_components[bp-blogs.php]" value="0" />
+
+					<?php endif; ?>
+
+					<?php if ( file_exists( BP_PLUGIN_DIR . '/bp-forums.php') ) : ?>
+
+						<tr>
+							<td><h3><?php _e( 'bbPress Forums', 'buddypress' ) ?></h3><p><?php _e( 'Activates bbPress forum support within BuddyPress groups or any other custom component.', 'buddypress' ) ?></p></td>
+							<td>
+								<input type="radio" name="bp_components[bp-forums.php]" value="1"<?php if ( !isset( $disabled_components['bp-forums.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?>  &nbsp;
+								<input type="radio" name="bp_components[bp-forums.php]" value="0"<?php if ( isset( $disabled_components['bp-forums.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
+							</td>
+						</tr>
+
+					<?php endif; ?>
+
+					<?php if ( file_exists( BP_PLUGIN_DIR . '/bp-friends.php') ) : ?>
+
+						<tr>
+							<td><h3><?php _e( 'Friends', 'buddypress' ) ?></h3><p><?php _e( 'Allows the creation of friend connections between users.', 'buddypress' ) ?></p></td>
+							<td>
+								<input type="radio" name="bp_components[bp-friends.php]" value="1"<?php if ( !isset( $disabled_components['bp-friends.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?>  &nbsp;
+								<input type="radio" name="bp_components[bp-friends.php]" value="0"<?php if ( isset( $disabled_components['bp-friends.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
+							</td>
+						</tr>
+
+					<?php endif; ?>
+
+					<?php if ( file_exists( BP_PLUGIN_DIR . '/bp-groups.php') ) : ?>
+
+						<tr>
+							<td><h3><?php _e( 'Groups', 'buddypress' ) ?></h3><p><?php _e( 'Let users create, join and participate in groups.', 'buddypress' ) ?></p></td>
+							<td>
+								<input type="radio" name="bp_components[bp-groups.php]" value="1"<?php if ( !isset( $disabled_components['bp-groups.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?>  &nbsp;
+								<input type="radio" name="bp_components[bp-groups.php]" value="0"<?php if ( isset( $disabled_components['bp-groups.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
+							</td>
+						</tr>
+
+					<?php endif; ?>
+
+					<?php if ( file_exists( BP_PLUGIN_DIR . '/bp-messages.php') ) : ?>
+
+						<tr>
+							<td><h3><?php _e( 'Private Messaging', 'buddypress' ) ?></h3><p><?php _e( 'Let users send private messages to one another. Site admins can also send site-wide notices.', 'buddypress' ) ?></p></td>
+							<td>
+								<input type="radio" name="bp_components[bp-messages.php]" value="1"<?php if ( !isset( $disabled_components['bp-messages.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?>  &nbsp;
+								<input type="radio" name="bp_components[bp-messages.php]" value="0"<?php if ( isset( $disabled_components['bp-messages.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
+							</td>
+						</tr>
+
+					<?php endif; ?>
+
+					<?php if ( file_exists( BP_PLUGIN_DIR . '/bp-xprofile.php') ) : ?>
+
+						<tr>
+							<td><h3><?php _e( 'Extended Profiles', 'buddypress' ) ?></h3><p><?php _e( 'Activates customizable profiles and avatars for site users.', 'buddypress' ) ?></p></td>
+							<td width="45%">
+								<input type="radio" name="bp_components[bp-xprofile.php]" value="1"<?php if ( !isset( $disabled_components['bp-xprofile.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?>  &nbsp;
+								<input type="radio" name="bp_components[bp-xprofile.php]" value="0"<?php if ( isset( $disabled_components['bp-xprofile.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
+							</td>
+						</tr>
+
+					<?php endif; ?>
+
+				</tbody>
 			</table>
 
@@ -252,5 +287,4 @@
 
 		</form>
-
 	</div>
 
Index: /trunk/bp-core/admin/bp-core-update.php
===================================================================
--- /trunk/bp-core/admin/bp-core-update.php	(revision 3727)
+++ /trunk/bp-core/admin/bp-core-update.php	(revision 3728)
@@ -12,6 +12,4 @@
 
 /**
- * bp_core_activate_site_options()
- *
  * When switching from single to multisite we need to copy blog options to
  * site options.
@@ -91,12 +89,12 @@
 		global $wp_rewrite;
 
+		// Setup wizard steps
 		if ( 'new' == $this->setup_type ) {
-			// Setup wizard steps
 			$steps = array(
 				__( 'Components', 'buddypress' ),
-				__( 'Pages', 'buddypress' ),
+				__( 'Pages',      'buddypress' ),
 				__( 'Permalinks', 'buddypress' ),
-				__( 'Theme', 'buddypress' ),
-				__( 'Finish', 'buddypress' )
+				__( 'Theme',      'buddypress' ),
+				__( 'Finish',     'buddypress' )
 			);
 
@@ -108,7 +106,7 @@
 				$steps = array_merge( array(), $steps );
 			}
+
+		// Update wizard steps
 		} else {
-			// Update wizard steps
-
 			if ( $this->is_network_activate )
 				$steps[] = __( 'Multisite Update', 'buddypress' );
@@ -167,19 +165,10 @@
 			<div id="bp-admin-header">
 				<h3><?php _e( 'BuddyPress', 'buddypress' ) ?></h3>
-				<h2>
-					<?php if ( 'update' == $this->setup_type ) : ?>
-
-						<?php _e( 'Update', 'buddypress' ) ?>
-
-					<?php else : ?>
-
-						<?php _e( 'Setup', 'buddypress' ) ?>
-
-					<?php endif; ?>
-				</h2>
+				<h2><?php ( 'update' == $this->setup_type ) ? _e( 'Update', 'buddypress' ) : _e( 'Setup', 'buddypress' ); ?></h2>
 			</div>
 
 			<?php
 				do_action( 'bp_admin_notices' );
+
 				$step_count  = count( $this->steps ) - 1;
 				$wiz_or_set  = $this->current_step >= $step_count ? 'bp-general-settings' : 'bp-wizard';
@@ -190,14 +179,23 @@
 				<div id="bp-admin-nav">
 					<ol>
+
 						<?php foreach( (array)$this->steps as $i => $name ) : ?>
+
 							<li<?php if ( $this->current_step == $i ) : ?> class="current"<?php endif; ?>>
 								<?php if ( $this->current_step > $i ) : ?>
+
 									<span class="complete">&nbsp;</span>
-								<?php else : ?>
-									<?php echo $i + 1 . '. ' ?>
-								<?php endif; ?>
-								<?php echo esc_attr( $name ) ?>
+
+								<?php else :
+
+									echo $i + 1 . '. ';
+
+								endif;
+								echo esc_attr( $name ) ?>
+
 							</li>
+
 						<?php endforeach; ?>
+
 					</ol>
 					<div class="prev-next submit clear">
@@ -207,4 +205,5 @@
 
 				<div id="bp-admin-content">
+
 					<?php switch ( $this->steps[$this->current_step] ) {
 						case __( 'Database Update', 'buddypress'):
@@ -233,17 +232,18 @@
 							break;
 					} ?>
+
 				</div>
 			</form>
-
-		</div>
+		</div>
+
 	<?php
 	}
 
-	/* Setup Step HTML */
+	// Setup Step HTML
 
 	function step_db_update() {
 		if ( !current_user_can( 'activate_plugins' ) )
-			return false;
-	?>
+			return false; ?>
+
 		<div class="prev-next submit clear">
 			<p><input type="submit" value="<?php _e( 'Update &amp; Next &rarr;', 'buddypress' ) ?>" name="submit" /></p>
@@ -257,6 +257,9 @@
 			<input type="hidden" name="save" value="db_update" />
 			<input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step ) ?>" />
+
 			<?php wp_nonce_field( 'bpwizard_db_update' ) ?>
-		</div>
+
+		</div>
+
 	<?php
 	}
@@ -319,5 +322,7 @@
 			<input type="hidden" name="save" value="ms_update" />
 			<input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step ) ?>" />
+
 			<?php wp_nonce_field( 'bpwizard_ms_update' ) ?>
+
 		</div>
 
@@ -327,7 +332,7 @@
 			});
 		</script>
+
 	<?php
 	}
-
 
 	function step_components() {
@@ -455,5 +460,5 @@
 		$disabled_components = apply_filters( 'bp_deactivated_components', get_site_option( 'bp-deactivated-components' ) );
 
-		/* Check for defined slugs */
+		// Check for defined slugs
 		if ( defined( 'BP_MEMBERS_SLUG' ) )
 			$members_slug = constant( 'BP_MEMBERS_SLUG' );
@@ -628,6 +633,5 @@
 
 		if ( !got_mod_rewrite() && !iis7_supports_permalinks() )
-			$prefix = '/index.php';
-	?>
+			$prefix = '/index.php'; ?>
 
 		<p><?php _e( "To make sure the pages we created in the previous step work correctly, you will need to enable permalink support on your site.", 'buddypress' ) ?></p>
@@ -654,5 +658,7 @@
 			<input type="hidden" name="save" value="permalinks" />
 			<input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step ) ?>" />
+
 			<?php wp_nonce_field( 'bpwizard_permalinks' ) ?>
+
 		</div>
 	<?php
@@ -665,9 +671,9 @@
 		require_once( ABSPATH . WPINC . '/plugin.php' );
 		$installed_plugins = get_plugins();
-		$installed_themes = get_themes();
+		$installed_themes  = get_themes();
 
 		$template_pack_installed = false;
-		$bp_autotheme_installed = false;
-		$bp_theme_installed = false;
+		$bp_autotheme_installed  = false;
+		$bp_theme_installed      = false;
 
 		foreach ( (array)$installed_plugins as $plugin ) {
@@ -700,4 +706,5 @@
 				</td>
 			</tr>
+
 			<?php /*
 			<tr>
@@ -714,4 +721,5 @@
 			</tr>
 			*/ ?>
+
 			<tr>
 				<th>
@@ -732,4 +740,5 @@
 				</td>
 			</tr>
+
 			<tr>
 				<th>
@@ -774,4 +783,5 @@
 			});
 		</script>
+
 	<?php
 	}
@@ -811,5 +821,5 @@
 	}
 
-	/* Save Step Methods */
+	// Save Step Methods
 
 	function step_db_update_save() {
@@ -837,7 +847,7 @@
 			// Transfer important settings from blog options to site options
 			$options = array(
-				'bp-db-version' => $this->current_version,
+				'bp-db-version'             => $this->current_version,
 				'bp-deactivated-components' => $disabled,
-				'avatar-default' => get_option( 'avatar-default' )
+				'avatar-default'            => get_option( 'avatar-default' )
 			);
 			bp_core_activate_site_options( $options );
@@ -853,8 +863,6 @@
 
 				$existing_pages = get_option( 'bp-pages' );
-
-				$bp_pages = $this->setup_pages( (array)$_POST['bp_pages'] );
-
-				$bp_pages = array_merge( (array)$existing_pages, (array)$bp_pages );
+				$bp_pages       = $this->setup_pages( (array)$_POST['bp_pages'] );
+				$bp_pages       = array_merge( (array)$existing_pages, (array)$bp_pages );
 
 				update_option( 'bp-pages', $bp_pages );
@@ -942,4 +950,5 @@
 				if ( !empty($permalink_structure) )
 					$permalink_structure = preg_replace( '#/+#', '/', '/' . $_POST['permalink_structure'] );
+
 				if ( ( defined( 'VHOST' ) && constant( 'VHOST' ) == 'no' ) && $permalink_structure != '' && $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path )
 					$permalink_structure = '/blog' . $permalink_structure;
@@ -965,7 +974,8 @@
 			if ( $iis7_permalinks || ( !$usingpi && !$writable ) ) {
 				function _bp_core_wizard_step_permalinks_message() {
-					global $wp_rewrite;
-
-					?><div id="message" class="updated fade"><p>
+					global $wp_rewrite; ?>
+
+					<div id="message" class="updated fade"><p>
+
 					<?php
 						_e( 'Oops, there was a problem creating a configuration file. ', 'buddypress' );
@@ -982,10 +992,15 @@
 						}
 					?>
+
 					<br /><br />
+
 					<?php
 						if ( empty( $iis7_permalinks ) )
 							_e( 'Paste all these rules into a new <code>.htaccess</code> file in the root of your WordPress installation and save the file. Once you\'re done, please hit the "Save and Next" button to continue.', 'buddypress' );
 					?>
-					</p></div><?php
+
+					</p></div>
+
+				<?php
 				}
 				add_action( 'bp_admin_notices', '_bp_core_wizard_step_permalinks_message' );
@@ -1078,5 +1093,5 @@
 	}
 
-	/* Database update methods based on version numbers */
+	// Database update methods based on version numbers
 	function update_1_3() {
 		// Run the schema install to update tables
@@ -1085,7 +1100,7 @@
 		// Delete old database version options
 		delete_site_option( 'bp-activity-db-version' );
-		delete_site_option( 'bp-blogs-db-version' );
-		delete_site_option( 'bp-friends-db-version' );
-		delete_site_option( 'bp-groups-db-version' );
+		delete_site_option( 'bp-blogs-db-version'    );
+		delete_site_option( 'bp-friends-db-version'  );
+		delete_site_option( 'bp-groups-db-version'   );
 		delete_site_option( 'bp-messages-db-version' );
 		delete_site_option( 'bp-xprofile-db-version' );
@@ -1216,14 +1231,16 @@
 		$message = __( 'Installation was successful. The available options have now been updated, please continue with your selection.', 'buddypress' );
 	else
-		return false;
-?>
+		return false; ?>
+
 	<div id="message" class="updated">
 		<p><?php echo esc_attr( $message ) ?></p>
 	</div>
+
 <?php
 }
 add_action( 'bp_admin_notices', 'bp_core_wizard_message' );
 
-/* Alter thickbox screens so the entire plugin download and install interface is contained within. */
+// Alter thickbox screens so the entire plugin download and install
+// interface is contained within.
 function bp_core_wizard_thickbox() {
 	$form_action = is_multisite() ? network_admin_url( add_query_arg( array( 'page' => 'bp-wizard', 'updated' => '1' ), 'admin.php' ) ) : admin_url( add_query_arg( array( 'page' => 'bp-wizard', 'updated' => '1' ), 'admin.php' ) ); ?>
@@ -1242,4 +1259,5 @@
 		}
 	</script>
+
 <?php
 }
@@ -1247,6 +1265,4 @@
 
 /**
- * bp_core_add_admin_menu()
- *
  * Adds the "BuddyPress" admin submenu item to the Site Admin tab.
  *
@@ -1291,6 +1307,6 @@
 
 	wp_enqueue_script( 'thickbox' );
-	wp_enqueue_style( 'thickbox' );
-?>
+	wp_enqueue_style( 'thickbox' ); ?>
+
 	<style type="text/css">
 		/* Wizard Icon */
@@ -1310,6 +1326,8 @@
 		}
 	</style>
+
 <?php
 }
 add_action( 'admin_head', 'bp_core_add_admin_menu_styles' );
+
 ?>
Index: /trunk/bp-core/bp-core-deprecated.php
===================================================================
--- /trunk/bp-core/bp-core-deprecated.php	(revision 3728)
+++ /trunk/bp-core/bp-core-deprecated.php	(revision 3728)
@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * Deprecated Functions
+ *
+ * @package BuddyPress
+ * @subpackage Core
+ *
+ */
+
+/**
+ * This function originally let plugins add support for pages in the root of the install.
+ * These pages are now handled by actual WordPress pages so this function is deprecated.
+ * It now simply facilitates backwards compatibility by adding a WP page if the plugin has not been
+ * updated to do so.
+ *
+ * @deprecated 1.3
+ * @deprecated Use wp_insert_post() to create a page
+ * @package BuddyPress Core
+ * @param $slug str The slug of the component
+ * @global $bp BuddyPress global settings
+ */
+function bp_core_add_root_component( $slug ) {
+	global $bp, $bp_pages;
+
+	_deprecated_function( __FUNCTION__, '1.3', 'wp_insert_post()' );
+	if ( empty( $bp_pages ) )
+		$bp_pages = bp_core_get_page_names();
+
+	$match = false;
+
+	// Check if the slug is registered in the $bp->pages global
+	foreach ( (array)$bp_pages as $key => $page ) {
+		if ( $key == $slug || $page->slug == $slug )
+			$match = true;
+	}
+
+	// If there was no match, add a page for this root component
+	if ( empty( $match ) ) {
+		$bp->add_root[] = $slug;
+		add_action( 'init', 'bp_core_create_root_component_page' );
+	}
+}
+
+function bp_core_create_root_component_page() {
+	global $bp;
+
+	$new_page_ids = array();
+
+	foreach ( (array)$bp->add_root as $slug )
+		$new_page_ids[$slug] = wp_insert_post( array( 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_title' => ucwords( $slug ), 'post_status' => 'publish', 'post_type' => 'page' ) );
+
+	$page_ids = bp_core_get_page_meta();
+	$page_ids = (array) $page_ids;
+	$page_ids = array_merge( (array) $new_page_ids, (array) $page_ids );
+
+	bp_core_update_page_meta( $page_ids );
+}
+
+
+?>
Index: /trunk/bp-core/bp-core-templatetags.php
===================================================================
--- /trunk/bp-core/bp-core-templatetags.php	(revision 3727)
+++ /trunk/bp-core/bp-core-templatetags.php	(revision 3728)
@@ -163,5 +163,5 @@
 
 	// Make sure we return no members if we looking at friendship requests and there are none.
-	if ( empty( $include ) && $bp->friends->slug == $bp->current_component && 'requests' == $bp->current_action )
+	if ( empty( $include ) && bp_is_current_component( $bp->friends->slug ) && 'requests' == $bp->current_action )
 		return false;
 
@@ -583,10 +583,14 @@
 function bp_get_options_nav() {
 	global $bp;
-
-	if ( count( $bp->bp_options_nav[$bp->current_component] ) < 1 )
+	
+	// If we are looking at a member profile, then the we can use the current component as an
+	// index. Otherwise we need to use the component's root_slug
+	$component_index = !empty( $bp->displayed_user ) ? $bp->current_component : bp_get_root_slug( $bp->current_component );
+	
+	if ( count( $bp->bp_options_nav[$component_index] ) < 1 )
 		return false;
 
 	/* Loop through each navigation item */
-	foreach ( (array)$bp->bp_options_nav[$bp->current_component] as $subnav_item ) {
+	foreach ( (array)$bp->bp_options_nav[$component_index] as $subnav_item ) {
 		if ( !$subnav_item['user_has_access'] )
 			continue;
@@ -1557,5 +1561,131 @@
 	}
 
+/**
+ * Echoes the output of bp_get_root_slug()
+ *
+ * @package BuddyPress Core
+ * @since 1.3
+ */
+function bp_root_slug( $component = '' ) {
+	echo bp_get_root_slug( $component );
+}
+	/**
+	 * Gets the root slug for a component slug
+	 *
+	 * In order to maintain backward compatibility, the following procedure is used:
+	 * 1) Use the short slug to get the canonical component name from the
+	 *    active component array
+	 * 2) Use the component name to get the root slug out of the appropriate part of the $bp
+	 *    global
+	 * 3) If nothing turns up, it probably means that $component is itself a root slug
+	 *
+	 * Example: If your groups directory is at /community/companies, this function first uses
+	 * the short slug 'companies' (ie the current component) to look up the canonical name
+	 * 'groups' in $bp->active_components. Then it uses 'groups' to get the root slug, from
+	 * $bp->groups->root_slug.
+	 *
+	 * @package BuddyPress Core
+	 * @since 1.3
+	 *
+	 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
+	 * @param string $component Optional. Defaults to the current component
+	 * @return string $root_slug The root slug
+	 */
+	function bp_get_root_slug( $component = '' ) {
+		global $bp;
+
+		$root_slug = '';
+
+		// Use current global component if none passed
+		if ( empty( $component ) )
+			$component = $bp->current_component;
+
+		// Component is active
+		if ( !empty( $bp->active_components[$component] ) ) {
+			$component_name = $bp->active_components[$component];
+
+			// Component has specific root slug
+			if ( !empty( $bp->{$component_name}->root_slug ) ) 
+				$root_slug = $bp->{$component_name}->root_slug;
+		}
+
+		// No specific root slug, so fall back to component slug
+		if ( empty( $root_slug ) )
+			$root_slug = $component;
+
+		return apply_filters( 'bp_get_root_slug', $root_slug, $component );
+	}
+
 /* Template is_() functions to determine the current page */
+
+/**
+ * Checks to see whether the current page belongs to the specified component
+ *
+ * This function is designed to be generous, accepting several different kinds
+ * of value for the $component parameter. It checks $component_name against:
+ * - the component's root_slug, which matches the page slug in $bp->pages
+ * - the component's regular slug
+ * - the component's id, or 'canonical' name
+ *
+ * @package BuddyPress Core
+ * @since 1.3
+ * @return bool Returns true if the component matches, or else false.
+ */
+function bp_is_current_component( $component ) {
+	global $bp;
+
+	$is_current_component = false;
+
+	if ( !empty( $bp->current_component ) ) {
+
+		// First, check to see whether $component_name and the current
+		// component are a simple match
+		if ( $bp->current_component == $component ) {
+			$is_current_component = true;
+
+		// Next, check to see whether $component is a canonical,
+		// non-translatable component name. If so, we can return its
+		// corresponding slug from $bp->active_components.
+		} else if ( $key = array_search( $component, $bp->active_components ) ) {
+			if ( $key === $bp->current_component )
+				$is_current_component = true;
+
+		// If we haven't found a match yet, check against the root_slugs
+		// created by $bp->pages
+		} else {
+			foreach ( $bp->active_components as $key => $id ) {
+				// If the $component parameter does not match the current_component,
+				// then move along, these are not the droids you are looking for
+				if ( $bp->{$id}->root_slug != $bp->current_component )
+					continue;
+
+				if ( $key == $component ) {
+					$is_current_component = true;
+					break;
+				}
+			}
+		}
+	}
+
+ 	return apply_filters( 'bp_is_current_component', $is_current_component, $component_name );
+}
+
+/**
+ * Checks to see if a component's URL should be in the root, not under a member page:
+ * eg: http://domain.com/groups/the-group NOT http://domain.com/members/andy/groups/the-group
+ *
+ * @package BuddyPress Core
+ * @return true if root component, else false.
+ */
+function bp_is_root_component( $component_name ) {
+	global $bp;
+
+	foreach ( (array) $bp->active_components as $key => $slug ) {
+		if ( $key == $component_name || $slug == $component_name )
+			return true;
+	}
+
+	return false;
+}
 
 /**
@@ -1591,5 +1721,5 @@
 		return true;
 
-	if ( !$bp->displayed_user->id && !$bp->is_single_item && ( !isset( $bp->is_directory ) || !$bp->is_directory ) && !bp_core_is_root_component( $bp->current_component ) )
+	if ( !$bp->displayed_user->id && !$bp->is_single_item && ( !isset( $bp->is_directory ) || !$bp->is_directory ) && !bp_is_root_component( $bp->current_component ) )
 		return true;
 
@@ -1661,7 +1791,5 @@
 
 function bp_is_profile_component() {
-	global $bp;
-
-	if ( BP_XPROFILE_SLUG == $bp->current_component )
+	if ( bp_is_current_component( BP_XPROFILE_SLUG ) )
 		return true;
 
@@ -1670,7 +1798,5 @@
 
 function bp_is_activity_component() {
-	global $bp;
-
-	if ( BP_ACTIVITY_SLUG == $bp->current_component )
+	if ( bp_is_current_component( BP_ACTIVITY_SLUG ) )
 		return true;
 
@@ -1679,7 +1805,5 @@
 
 function bp_is_blogs_component() {
-	global $bp;
-
-	if ( is_multisite() && BP_BLOGS_SLUG == $bp->current_component )
+	if ( is_multisite() && bp_is_current_component( BP_BLOGS_SLUG ) )
 		return true;
 
@@ -1688,7 +1812,5 @@
 
 function bp_is_messages_component() {
-	global $bp;
-
-	if ( BP_MESSAGES_SLUG == $bp->current_component )
+	if ( bp_is_current_component( BP_MESSAGES_SLUG ) )
 		return true;
 
@@ -1697,7 +1819,5 @@
 
 function bp_is_friends_component() {
-	global $bp;
-
-	if ( BP_FRIENDS_SLUG == $bp->current_component )
+	if ( bp_is_current_component( BP_FRIENDS_SLUG ) )
 		return true;
 
@@ -1706,7 +1826,5 @@
 
 function bp_is_groups_component() {
-	global $bp;
-
-	if ( BP_GROUPS_SLUG == $bp->current_component )
+	if ( bp_is_current_component( BP_GROUPS_SLUG ) )
 		return true;
 
@@ -1715,7 +1833,5 @@
 
 function bp_is_settings_component() {
-	global $bp;
-
-	if ( BP_SETTINGS_SLUG == $bp->current_component )
+	if ( bp_is_current_component( BP_SETTINGS_SLUG ) )
 		return true;
 
@@ -1735,5 +1851,5 @@
 	global $bp;
 
-	if ( $bp->activity->slug == $bp->current_component )
+	if ( bp_is_current_component( $bp->activity->slug ) )
 		return true;
 
@@ -1744,5 +1860,5 @@
 	global $bp;
 
-	if ( $bp->activity->slug == $bp->current_component && 'my-friends' == $bp->current_action )
+	if ( bp_is_current_component( $bp->activity->slug ) && 'my-friends' == $bp->current_action )
 		return true;
 
@@ -1753,5 +1869,5 @@
 	global $bp;
 
-	if ( BP_ACTIVITY_SLUG == $bp->current_component && is_numeric( $bp->current_action ) )
+	if ( bp_is_current_component( BP_ACTIVITY_SLUG ) && is_numeric( $bp->current_action ) )
 		return true;
 
@@ -1762,5 +1878,5 @@
 	global $bp;
 
-	if ( defined( 'BP_XPROFILE_SLUG' ) && BP_XPROFILE_SLUG == $bp->current_component || isset( $bp->core->profile->slug ) && $bp->core->profile->slug == $bp->current_component )
+	if ( defined( 'BP_XPROFILE_SLUG' ) && bp_is_current_component( BP_XPROFILE_SLUG ) || isset( $bp->core->profile->slug ) && bp_is_current_component( $bp->core->profile->slug ) )
 		return true;
 
@@ -1771,5 +1887,5 @@
 	global $bp;
 
-	if ( BP_XPROFILE_SLUG == $bp->current_component && 'edit' == $bp->current_action )
+	if ( bp_is_current_component( BP_XPROFILE_SLUG ) && 'edit' == $bp->current_action )
 		return true;
 
@@ -1780,5 +1896,5 @@
 	global $bp;
 
-	if ( BP_XPROFILE_SLUG == $bp->current_component && 'change-avatar' == $bp->current_action )
+	if ( bp_is_current_component( BP_XPROFILE_SLUG ) && 'change-avatar' == $bp->current_action )
 		return true;
 
@@ -1788,6 +1904,6 @@
 function bp_is_user_groups() {
 	global $bp;
-
-	if ( $bp->groups->slug == $bp->current_component )
+	
+	if ( bp_is_current_component( BP_GROUPS_SLUG ) )
 		return true;
 
@@ -1797,6 +1913,6 @@
 function bp_is_group() {
 	global $bp;
-
-	if ( BP_GROUPS_SLUG == $bp->current_component && isset( $bp->groups->current_group ) && $bp->groups->current_group )
+	
+	if ( bp_is_current_component( BP_GROUPS_SLUG ) && isset( $bp->groups->current_group ) && $bp->groups->current_group )
 		return true;
 
@@ -1807,5 +1923,5 @@
 	global $bp;
 
-	if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && ( !$bp->current_action || 'home' == $bp->current_action ) )
+	if ( bp_is_current_component( BP_GROUPS_SLUG ) && $bp->is_single_item && ( !$bp->current_action || 'home' == $bp->current_action ) )
 		return true;
 
@@ -1816,5 +1932,5 @@
 	global $bp;
 
-	if ( BP_GROUPS_SLUG == $bp->current_component && 'create' == $bp->current_action )
+	if ( bp_is_current_component( BP_GROUPS_SLUG ) && 'create' == $bp->current_action )
 		return true;
 
@@ -1826,5 +1942,5 @@
 	global $bp;
 
-	if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'admin' == $bp->current_action )
+	if ( bp_is_current_component( BP_GROUPS_SLUG ) && $bp->is_single_item && 'admin' == $bp->current_action )
 		return true;
 
@@ -1835,5 +1951,5 @@
 	global $bp;
 
-	if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'forum' == $bp->current_action )
+	if ( bp_is_current_component( BP_GROUPS_SLUG ) && $bp->is_single_item && 'forum' == $bp->current_action )
 		return true;
 
@@ -1844,5 +1960,5 @@
 	global $bp;
 
-	if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'activity' == $bp->current_action )
+	if ( bp_is_current_component( BP_GROUPS_SLUG ) && $bp->is_single_item && 'activity' == $bp->current_action )
 		return true;
 
@@ -1853,5 +1969,5 @@
 	global $bp;
 
-	if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'forum' == $bp->current_action && isset( $bp->action_variables[0] ) && 'topic' == $bp->action_variables[0] )
+	if ( bp_is_current_component( BP_GROUPS_SLUG ) && $bp->is_single_item && 'forum' == $bp->current_action && isset( $bp->action_variables[0] ) && 'topic' == $bp->action_variables[0] )
 		return true;
 
@@ -1862,5 +1978,5 @@
 	global $bp;
 
-	if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'forum' == $bp->current_action && isset( $bp->action_variables[0] ) && 'topic' == $bp->action_variables[0] && isset( $bp->action_variables[2] ) && 'edit' == $bp->action_variables[2] )
+	if ( bp_is_current_component( BP_GROUPS_SLUG ) && $bp->is_single_item && 'forum' == $bp->current_action && isset( $bp->action_variables[0] ) && 'topic' == $bp->action_variables[0] && isset( $bp->action_variables[2] ) && 'edit' == $bp->action_variables[2] )
 		return true;
 
@@ -1871,5 +1987,5 @@
 	global $bp;
 
-	if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'members' == $bp->current_action )
+	if ( bp_is_current_component( BP_GROUPS_SLUG ) && $bp->is_single_item && 'members' == $bp->current_action )
 		return true;
 
@@ -1880,5 +1996,5 @@
 	global $bp;
 
-	if ( BP_GROUPS_SLUG == $bp->current_component && 'send-invites' == $bp->current_action )
+	if ( bp_is_current_component( BP_GROUPS_SLUG ) && 'send-invites' == $bp->current_action )
 		return true;
 
@@ -1889,5 +2005,5 @@
 	global $bp;
 
-	if ( BP_GROUPS_SLUG == $bp->current_component && 'request-membership' == $bp->current_action )
+	if ( bp_is_current_component( BP_GROUPS_SLUG ) && 'request-membership' == $bp->current_action )
 		return true;
 
@@ -1898,5 +2014,5 @@
 	global $bp;
 
-	if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'leave-group' == $bp->current_action )
+	if ( bp_is_current_component( BP_GROUPS_SLUG ) && $bp->is_single_item && 'leave-group' == $bp->current_action )
 		return true;
 
@@ -1907,5 +2023,5 @@
 	global $bp;
 
-	if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item )
+	if ( bp_is_current_component( BP_GROUPS_SLUG ) && $bp->is_single_item )
 		return true;
 
@@ -1916,5 +2032,5 @@
 	global $bp;
 
-	if ( is_multisite() && BP_BLOGS_SLUG == $bp->current_component )
+	if ( is_multisite() && bp_is_current_component( BP_BLOGS_SLUG ) )
 		return true;
 
@@ -1925,5 +2041,5 @@
 	global $bp;
 
-	if ( is_multisite() && BP_BLOGS_SLUG == $bp->current_component && 'recent-posts' == $bp->current_action )
+	if ( is_multisite() && bp_is_current_component( BP_BLOGS_SLUG ) && 'recent-posts' == $bp->current_action )
 		return true;
 
@@ -1934,5 +2050,5 @@
 	global $bp;
 
-	if ( is_multisite() && BP_BLOGS_SLUG == $bp->current_component && 'recent-comments' == $bp->current_action )
+	if ( is_multisite() && bp_is_current_component( BP_BLOGS_SLUG ) && 'recent-comments' == $bp->current_action )
 		return true;
 
@@ -1943,5 +2059,5 @@
 	global $bp;
 
-	if ( is_multisite() && BP_BLOGS_SLUG == $bp->current_component && 'create' == $bp->current_action )
+	if ( is_multisite() && bp_is_current_component( BP_BLOGS_SLUG ) && 'create' == $bp->current_action )
 		return true;
 
@@ -1950,7 +2066,5 @@
 
 function bp_is_user_friends() {
-	global $bp;
-
-	if ( BP_FRIENDS_SLUG == $bp->current_component )
+	if ( bp_is_current_component( BP_FRIENDS_SLUG ) )
 		return true;
 
@@ -1961,5 +2075,5 @@
 	global $bp;
 
-	if ( BP_FRIENDS_SLUG == $bp->current_component && 'requests' == $bp->current_action )
+	if ( bp_is_current_component( BP_FRIENDS_SLUG ) && 'requests' == $bp->current_action )
 		return true;
 
@@ -1968,7 +2082,5 @@
 
 function bp_is_user_messages() {
-	global $bp;
-
-	if ( BP_MESSAGES_SLUG == $bp->current_component )
+	if ( bp_is_current_component( BP_MESSAGES_SLUG ) )
 		return true;
 
@@ -1979,5 +2091,5 @@
 	global $bp;
 
-	if ( BP_MESSAGES_SLUG == $bp->current_component && ( !$bp->current_action || 'inbox' == $bp->current_action ) )
+	if ( bp_is_current_component( BP_MESSAGES_SLUG ) && ( !$bp->current_action || 'inbox' == $bp->current_action ) )
 		return true;
 
@@ -1988,5 +2100,5 @@
 	global $bp;
 
-	if ( BP_MESSAGES_SLUG == $bp->current_component && 'sentbox' == $bp->current_action )
+	if ( bp_is_current_component( BP_MESSAGES_SLUG ) && 'sentbox' == $bp->current_action )
 		return true;
 
@@ -1998,5 +2110,5 @@
 	global $bp;
 
-	if ( BP_MESSAGES_SLUG == $bp->current_component && 'notices' == $bp->current_action )
+	if ( bp_is_current_component( BP_MESSAGES_SLUG ) && 'notices' == $bp->current_action )
 		return true;
 
@@ -2008,5 +2120,5 @@
 	global $bp;
 
-	if ( BP_MESSAGES_SLUG == $bp->current_component && 'compose' == $bp->current_action )
+	if ( bp_is_current_component( BP_MESSAGES_SLUG ) && 'compose' == $bp->current_action )
 		return true;
 
@@ -2024,7 +2136,5 @@
 
 function bp_is_activation_page() {
-	global $bp;
-
-	if ( BP_ACTIVATION_SLUG == $bp->current_component )
+	if ( bp_is_current_component( BP_ACTIVATION_SLUG ) )
 		return true;
 
@@ -2033,7 +2143,5 @@
 
 function bp_is_register_page() {
-	global $bp;
-
-	if ( BP_REGISTER_SLUG == $bp->current_component )
+	if ( bp_is_current_component( BP_REGISTER_SLUG ) )
 		return true;
 
Index: /trunk/bp-core/css/admin.dev.css
===================================================================
--- /trunk/bp-core/css/admin.dev.css	(revision 3727)
+++ /trunk/bp-core/css/admin.dev.css	(revision 3728)
@@ -1,2 +1,6 @@
+html {
+	padding-top: 28px !important;
+}
+
 div#bp-admin {
 	margin: 25px 15px 25px 0;
@@ -9,5 +13,5 @@
 
 div#bp-admin div#bp-admin-header {
-	height: 45px;
+	
 }
 
Index: /trunk/bp-forums.php
===================================================================
--- /trunk/bp-forums.php	(revision 3727)
+++ /trunk/bp-forums.php	(revision 3728)
@@ -1,5 +1,5 @@
 <?php
 
-/* Define the parent forum ID */
+// Define the parent forum ID
 if ( !defined( 'BP_FORUMS_PARENT_FORUM_ID' ) )
 	define( 'BP_FORUMS_PARENT_FORUM_ID', 1 );
@@ -19,13 +19,17 @@
 function bp_forums_setup() {
 	global $bp;
-        
-        if ( !defined( 'BP_FORUMS_SLUG' ) )
-                define ( 'BP_FORUMS_SLUG', $bp->pages->forums->slug );
+
+	if ( !defined( 'BP_FORUMS_SLUG' ) )
+		define ( 'BP_FORUMS_SLUG', bp_core_component_slug_from_root_slug( $bp->pages->forums->slug ) );
 
 	// For internal identification
 	$bp->forums->id = 'forums';
 
+	// Slugs
+	$bp->forums->slug      = BP_FORUMS_SLUG;
+	$bp->forums->root_slug = $bp->pages->forums->slug;
+
+	// Images
 	$bp->forums->image_base = BP_PLUGIN_URL . '/bp-forums/images';
-	$bp->forums->slug = BP_FORUMS_SLUG;
 
 	if ( isset( $bp->site_options['bb-config-location'] ) )
@@ -81,11 +85,10 @@
 		do_action( 'bbpress_init' );
 
-		/* Check to see if the user has posted a new topic from the forums page. */
+		// Check to see if the user has posted a new topic from the forums page.
 		if ( isset( $_POST['submit_topic'] ) && function_exists( 'bp_forums_new_topic' ) ) {
-			/* Check the nonce */
 			check_admin_referer( 'bp_forums_new_topic' );
 
 			if ( $bp->groups->current_group = groups_get_group( array( 'group_id' => $_POST['topic_group_id'] ) ) ) {
-				/* Auto join this user if they are not yet a member of this group */
+				// Auto join this user if they are not yet a member of this group
 				if ( !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
 					groups_join_group( $bp->groups->current_group->id, $bp->groups->current_group->id );
@@ -134,10 +137,10 @@
 	require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-admin.php' );
 
-	/* Add the administration tab under the "Site Admin" tab for site administrators */
+	// Add the administration tab under the "Site Admin" tab for site administrators
 	add_submenu_page( 'bp-general-settings', __( 'Forums Setup', 'buddypress' ), __( 'Forums Setup', 'buddypress' ), 'manage_options', 'bb-forums-setup', "bp_forums_bbpress_admin" );
 }
 add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', 'bp_forums_add_admin_menu' );
 
-/* Forum Functions */
+/** Forum Functions ***********************************************************/
 
 function bp_forums_get_forum( $forum_id ) {
@@ -150,8 +153,8 @@
 
 	$defaults = array(
-		'forum_name' => '',
-		'forum_desc' => '',
-		'forum_parent_id' => BP_FORUMS_PARENT_FORUM_ID,
-		'forum_order' => false,
+		'forum_name'        => '',
+		'forum_desc'        => '',
+		'forum_parent_id'   => BP_FORUMS_PARENT_FORUM_ID,
+		'forum_order'       => false,
 		'forum_is_category' => 0
 	);
@@ -182,5 +185,5 @@
 }
 
-/* Topic Functions */
+/** Topic Functions ***********************************************************/
 
 function bp_forums_get_forum_topics( $args = '' ) {
@@ -207,20 +210,20 @@
 			$query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'topic_author_id' => $user_id, 'per_page' => $per_page, 'page' => $page, 'number' => $per_page, 'exclude' => $exclude, 'topic_title' => $filter, 'sticky' => $show_stickies ), 'get_latest_topics' );
 			$topics =& $query->results;
-		break;
+			break;
 
 		case 'popular':
 			$query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'topic_author_id' => $user_id, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_posts', 'topic_title' => $filter, 'sticky' => $show_stickies ) );
 			$topics =& $query->results;
-		break;
+			break;
 
 		case 'unreplied':
 			$query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'topic_author_id' => $user_id, 'post_count' => 1, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_time', 'topic_title' => $filter, 'sticky' => $show_stickies ) );
 			$topics =& $query->results;
-		break;
+			break;
 
 		case 'tags':
 			$query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'topic_author_id' => $user_id, 'tag' => $filter, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_time', 'sticky' => $show_stickies ) );
 			$topics =& $query->results;
-		break;
+			break;
 	}
 
@@ -247,16 +250,16 @@
 
 	$defaults = array(
-		'topic_title' => '',
-		'topic_slug' => '',
-		'topic_text' => '',
-		'topic_poster' => $bp->loggedin_user->id, // accepts ids
-		'topic_poster_name' => $bp->loggedin_user->fullname, // accept names
-		'topic_last_poster' => $bp->loggedin_user->id, // accepts ids
+		'topic_title'            => '',
+		'topic_slug'             => '',
+		'topic_text'             => '',
+		'topic_poster'           => $bp->loggedin_user->id, // accepts ids
+		'topic_poster_name'      => $bp->loggedin_user->fullname, // accept names
+		'topic_last_poster'      => $bp->loggedin_user->id, // accepts ids
 		'topic_last_poster_name' => $bp->loggedin_user->fullname, // accept names
-		'topic_start_time' => bp_core_current_time(),
-		'topic_time' => bp_core_current_time(),
-		'topic_open' => 1,
-		'topic_tags' => false, // accepts array or comma delim
-		'forum_id' => 0 // accepts ids or slugs
+		'topic_start_time'       => bp_core_current_time(),
+		'topic_time'             => bp_core_current_time(),
+		'topic_open'             => 1,
+		'topic_tags'             => false, // accepts array or comma delim
+		'forum_id'               => 0 // accepts ids or slugs
 	);
 
@@ -275,5 +278,5 @@
 		return false;
 
-	/* Now insert the first post. */
+	// Now insert the first post.
 	if ( !bp_forums_insert_post( array( 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $topic_time, 'poster_id' => $topic_poster ) ) )
 		return false;
@@ -290,33 +293,33 @@
 
 	$defaults = array(
+		'topic_id'    => false,
+		'topic_title' => '',
+		'topic_text'  => ''
+	);
+
+	$r = wp_parse_args( $args, $defaults );
+	extract( $r, EXTR_SKIP );
+
+	if ( !$topic_id = bb_insert_topic( array( 'topic_id' => $topic_id, 'topic_title' => stripslashes( $topic_title ) ) ) )
+		return false;
+
+	if ( !$post = bb_get_first_post( $topic_id ) )
+		return false;
+
+	// Update the first post
+	if ( !$post = bp_forums_insert_post( array( 'post_id' => $post->post_id, 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $post->post_time, 'poster_id' => $post->poster_id, 'poster_ip' => $post->poster_ip, 'post_status' => $post->post_status, 'post_position' => $post->post_position ) ) )
+		return false;
+
+	return bp_forums_get_topic_details( $topic_id );
+}
+
+function bp_forums_sticky_topic( $args = '' ) {
+	global $bp;
+
+	do_action( 'bbpress_init' );
+
+	$defaults = array(
 		'topic_id' => false,
-		'topic_title' => '',
-		'topic_text' => ''
-	);
-
-	$r = wp_parse_args( $args, $defaults );
-	extract( $r, EXTR_SKIP );
-
-	if ( !$topic_id = bb_insert_topic( array( 'topic_id' => $topic_id, 'topic_title' => stripslashes( $topic_title ) ) ) )
-		return false;
-
-	if ( !$post = bb_get_first_post( $topic_id ) )
-		return false;
-
-	/* Update the first post */
-	if ( !$post = bp_forums_insert_post( array( 'post_id' => $post->post_id, 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $post->post_time, 'poster_id' => $post->poster_id, 'poster_ip' => $post->poster_ip, 'post_status' => $post->post_status, 'post_position' => $post->post_position ) ) )
-		return false;
-
-	return bp_forums_get_topic_details( $topic_id );
-}
-
-function bp_forums_sticky_topic( $args = '' ) {
-	global $bp;
-
-	do_action( 'bbpress_init' );
-
-	$defaults = array(
-		'topic_id' => false,
-		'mode' => 'stick' // stick/unstick
+		'mode'     => 'stick' // stick/unstick
 	);
 
@@ -339,5 +342,5 @@
 	$defaults = array(
 		'topic_id' => false,
-		'mode' => 'close' // stick/unstick
+		'mode'     => 'close' // stick/unstick
 	);
 
@@ -398,16 +401,16 @@
 		return $topics;
 
-	/* Get the topic ids */
+	// 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++ ) {
 		foreach ( (array)$poster_details as $poster ) {
 			if ( $poster->topic_id == $topics[$i]->topic_id ) {
-				$topics[$i]->topic_last_poster_email = $poster->user_email;
-				$topics[$i]->topic_last_poster_nicename = $poster->user_nicename;
-				$topics[$i]->topic_last_poster_login = $poster->user_login;
+				$topics[$i]->topic_last_poster_email       = $poster->user_email;
+				$topics[$i]->topic_last_poster_nicename    = $poster->user_nicename;
+				$topics[$i]->topic_last_poster_login       = $poster->user_login;
 				$topics[$i]->topic_last_poster_displayname = $poster->display_name;
 			}
@@ -415,5 +418,5 @@
 	}
 
-	/* 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} )" ) );
@@ -429,5 +432,5 @@
 }
 
-/* Post Functions */
+/** Post Functions ************************************************************/
 
 function bp_forums_get_topic_posts( $args = '' ) {
@@ -436,12 +439,12 @@
 	$defaults = array(
 		'topic_id' => false,
-		'page' => 1,
+		'page'     => 1,
 		'per_page' => 15,
-		'order' => 'ASC'
-	);
-
-	$args = wp_parse_args( $args, $defaults );
-
+		'order'    => 'ASC'
+	);
+
+	$args  = wp_parse_args( $args, $defaults );
 	$query = new BB_Query( 'post', $args, 'get_thread' );
+
 	return bp_forums_get_post_extras( $query->results );
 }
@@ -473,11 +476,11 @@
 
 	$defaults = array(
-		'post_id' => false,
-		'topic_id' => false,
-		'post_text' => '',
-		'post_time' => bp_core_current_time(),
-		'poster_id' => $bp->loggedin_user->id, // accepts ids or names
-		'poster_ip' => $_SERVER['REMOTE_ADDR'],
-		'post_status' => 0, // use bb_delete_post() instead
+		'post_id'       => false,
+		'topic_id'      => false,
+		'post_text'     => '',
+		'post_time'     => bp_core_current_time(),
+		'poster_id'     => $bp->loggedin_user->id, // accepts ids or names
+		'poster_ip'     => $_SERVER['REMOTE_ADDR'],
+		'post_status'   => 0, // use bb_delete_post() instead
 		'post_position' => false
 	);
@@ -503,5 +506,5 @@
 	$post_id = bb_insert_post( array( 'post_id' => $post_id, 'topic_id' => $topic_id, 'post_text' => stripslashes( trim( $post_text ) ), 'post_time' => $post_time, 'poster_id' => $poster_id, 'poster_ip' => $poster_ip, 'post_status' => $post_status, 'post_position' => $post_position ) );
 
-	if ( $post_id )
+	if ( !empty( $post_id ) )
 		do_action( 'bp_forums_new_post', $post_id );
 
@@ -515,9 +518,9 @@
 		return $posts;
 
-	/* Get the user ids */
+	// 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} )" ) );
 
@@ -525,13 +528,13 @@
 		foreach ( (array)$poster_details as $poster ) {
 			if ( $poster->user_id == $posts[$i]->poster_id ) {
-				$posts[$i]->poster_email = $poster->user_email;
-				$posts[$i]->poster_login = $poster->user_nicename;
+				$posts[$i]->poster_email    = $poster->user_email;
+				$posts[$i]->poster_login    = $poster->user_nicename;
 				$posts[$i]->poster_nicename = $poster->user_login;
-				$posts[$i]->poster_name = $poster->display_name;
+				$posts[$i]->poster_name     = $poster->display_name;
 			}
 		}
 	}
 
-	/* 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} )" ) );
@@ -552,5 +555,5 @@
 	do_action( 'bbpress_init' );
 
-	/* Need to find a bbPress function that does this */
+	// Need to find a bbPress function that does this
 	return $wpdb->get_results( $wpdb->prepare( "SELECT topics, posts from {$bbdb->forums} WHERE forum_id = %d", $forum_id ) );
 }
@@ -586,4 +589,5 @@
 add_action( 'bp_forums_new_forum', 'bp_core_clear_cache' );
 add_action( 'bp_forums_new_topic', 'bp_core_clear_cache' );
-add_action( 'bp_forums_new_post', 'bp_core_clear_cache' );
+add_action( 'bp_forums_new_post',  'bp_core_clear_cache' );
+
 ?>
Index: /trunk/bp-friends.php
===================================================================
--- /trunk/bp-friends.php	(revision 3727)
+++ /trunk/bp-friends.php	(revision 3728)
@@ -1,26 +1,30 @@
 <?php
 
+// Required Files
+require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-classes.php' );
+require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-templatetags.php' );
+
 define ( 'BP_FRIENDS_DB_VERSION', '1800' );
 
-/* Define the slug for the component */
+// Define the slug for the component
 if ( !defined( 'BP_FRIENDS_SLUG' ) )
 	define ( 'BP_FRIENDS_SLUG', 'friends' );
 
-require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-classes.php' );
-require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-templatetags.php' );
-
 function friends_setup_globals() {
 	global $bp;
 
-	/* For internal identification */
+	// For internal identification
 	$bp->friends->id = 'friends';
 
+	// Slug
 	$bp->friends->slug = BP_FRIENDS_SLUG;
 
+	// Table
 	$bp->friends->table_name = $bp->table_prefix . 'bp_friends';
 
+	// Notifications
 	$bp->friends->format_notification_function = 'friends_format_notifications';
 
-	/* Register this in the active components array */
+	// Register this in the active components array
 	$bp->active_components[$bp->friends->slug] = $bp->friends->id;
 
@@ -32,12 +36,12 @@
 	global $bp;
 
-	/* Add 'Friends' to the main navigation */
+	// Add 'Friends' to the main navigation
 	bp_core_new_nav_item( array( 'name' => sprintf( __( 'Friends <span>(%d)</span>', 'buddypress' ), friends_get_total_friend_count() ), 'slug' => $bp->friends->slug, 'position' => 60, 'screen_function' => 'friends_screen_my_friends', 'default_subnav_slug' => 'my-friends', 'item_css_id' => $bp->friends->id ) );
 
 	$friends_link = $bp->loggedin_user->domain . $bp->friends->slug . '/';
 
-	/* Add the subnav items to the friends nav item */
-	bp_core_new_subnav_item( array( 'name' => __( 'My Friends', 'buddypress' ), 'slug' => 'my-friends', 'parent_url' => $friends_link, 'parent_slug' => $bp->friends->slug, 'screen_function' => 'friends_screen_my_friends', 'position' => 10, 'item_css_id' => 'friends-my-friends' ) );
-	bp_core_new_subnav_item( array( 'name' => __( 'Requests', 'buddypress' ), 'slug' => 'requests', 'parent_url' => $friends_link, 'parent_slug' => $bp->friends->slug, 'screen_function' => 'friends_screen_requests', 'position' => 20, 'user_has_access' => bp_is_my_profile() ) );
+	// Add the subnav items to the friends nav item
+	bp_core_new_subnav_item( array( 'name' => __( 'My Friends', 'buddypress' ), 'slug' => 'my-friends', 'parent_url' => $friends_link, 'parent_slug' => $bp->friends->slug, 'screen_function' => 'friends_screen_my_friends', 'position' => 10, 'item_css_id'     => 'friends-my-friends' ) );
+	bp_core_new_subnav_item( array( 'name' => __( 'Requests',   'buddypress' ), 'slug' => 'requests',   'parent_url' => $friends_link, 'parent_slug' => $bp->friends->slug, 'screen_function' => 'friends_screen_requests',   'position' => 20, 'user_has_access' => bp_is_my_profile()   ) );
 
 	if ( $bp->current_component == $bp->friends->slug ) {
@@ -77,5 +81,5 @@
 
 	if ( isset( $bp->action_variables[0] ) && isset( $bp->action_variables[1] ) && 'accept' == $bp->action_variables[0] && is_numeric( $bp->action_variables[1] ) ) {
-		/* Check the nonce */
+		// Check the nonce
 		check_admin_referer( 'friends_accept_friendship' );
 
@@ -88,5 +92,5 @@
 
 	} elseif ( isset( $bp->action_variables[0] ) && isset( $bp->action_variables[1] ) && 'reject' == $bp->action_variables[0] && is_numeric( $bp->action_variables[1] ) ) {
-		/* Check the nonce */
+		// Check the nonce
 		check_admin_referer( 'friends_reject_friendship' );
 
@@ -110,12 +114,12 @@
 	global $bp;
 
-	$send_requests = get_user_meta( $bp->displayed_user->id, 'notification_friends_friendship_request', true );
-	if ( !$send_requests )
-		$send_requests = 'yes';
-
-	$accept_requests = get_user_meta( $bp->displayed_user->id, 'notification_friends_friendship_accepted', true );
-	if ( !$accept_requests )
+	
+	if ( !$send_requests = get_user_meta( $bp->displayed_user->id, 'notification_friends_friendship_request', true ) )
+		$send_requests   = 'yes';
+
+	if ( !$accept_requests = get_user_meta( $bp->displayed_user->id, 'notification_friends_friendship_accepted', true ) )
 		$accept_requests = 'yes';
 ?>
+
 	<table class="notification-settings zebra" id="friends-notification-settings">
 		<thead>
@@ -143,6 +147,8 @@
 
 			<?php do_action( 'friends_screen_notification_settings' ); ?>
+
 		</tbody>
 	</table>
+
 <?php
 }
@@ -184,4 +190,5 @@
 			bp_core_add_message( __( 'Friendship requested', 'buddypress' ) );
 		}
+
 	} else if ( 'is_friend' == $friendship_status ) {
 		bp_core_add_message( __( 'You are already friends with this user', 'buddypress' ), 'error' );
@@ -222,4 +229,5 @@
 			bp_core_add_message( __( 'Friendship canceled', 'buddypress' ) );
 		}
+
 	} else if ( 'is_friends' == $friendship_status ) {
 		bp_core_add_message( __( 'You are not yet friends with this user', 'buddypress' ), 'error' );
@@ -248,15 +256,15 @@
 		return false;
 
-	$defaults = array(
-		'user_id' => $bp->loggedin_user->id,
-		'action' => '',
-		'content' => '',
-		'primary_link' => '',
-		'component' => $bp->friends->id,
-		'type' => false,
-		'item_id' => false,
+	$defaults = array (
+		'user_id'           => $bp->loggedin_user->id,
+		'action'            => '',
+		'content'           => '',
+		'primary_link'      => '',
+		'component'         => $bp->friends->id,
+		'type'              => false,
+		'item_id'           => false,
 		'secondary_item_id' => false,
-		'recorded_time' => bp_core_current_time(),
-		'hide_sitewide' => false
+		'recorded_time'     => bp_core_current_time(),
+		'hide_sitewide'     => false
 	);
 
@@ -300,5 +308,5 @@
 				return apply_filters( 'bp_friends_single_friendship_accepted_notification', '<a href="' . $user_url . '?new" title="' . $user_fullname .'\'s profile">' . sprintf( __( '%s accepted your friendship request', 'buddypress' ), $user_fullname ) . '</a>', $user_fullname );
 			}
-		break;
+			break;
 
 		case 'friendship_request':
@@ -310,5 +318,5 @@
 				return apply_filters( 'bp_friends_single_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests/?new" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have a friendship request from %s', 'buddypress' ), $user_fullname ) . '</a>', $user_fullname );
 			}
-		break;
+			break;
 	}
 
@@ -337,8 +345,8 @@
 
 	$friendship->initiator_user_id = $initiator_userid;
-	$friendship->friend_user_id = $friend_userid;
-	$friendship->is_confirmed = 0;
-	$friendship->is_limited = 0;
-	$friendship->date_created = bp_core_current_time();
+	$friendship->friend_user_id    = $friend_userid;
+	$friendship->is_confirmed      = 0;
+	$friendship->is_limited        = 0;
+	$friendship->date_created      = bp_core_current_time();
 
 	if ( $force_accept )
@@ -370,5 +378,5 @@
 
 	$friendship_id = BP_Friends_Friendship::get_friendship_id( $initiator_userid, $friend_userid );
-	$friendship = new BP_Friends_Friendship( $friendship_id );
+	$friendship    = new BP_Friends_Friendship( $friendship_id );
 
 	// Remove the activity stream item for the user who canceled the friendship
@@ -427,4 +435,5 @@
 
 		do_action( 'friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
+
 		return true;
 	}
@@ -456,10 +465,10 @@
 }
 
+// Returns - 'is_friend', 'not_friends', 'pending'
 function friends_check_friendship_status( $user_id, $possible_friend_id ) {
-	/* Returns - 'is_friend', 'not_friends', 'pending' */
 	return BP_Friends_Friendship::check_is_friend( $user_id, $possible_friend_id );
 }
 
-function friends_get_total_friend_count( $user_id = false ) {
+function friends_get_total_friend_count( $user_id = 0 ) {
 	global $bp;
 
@@ -504,13 +513,13 @@
 }
 
-function friends_get_recently_active( $user_id, $per_page = false, $page = false, $filter = false ) {
+function friends_get_recently_active( $user_id, $per_page = 0, $page = 0, $filter = '' ) {
 	return apply_filters( 'friends_get_recently_active', BP_Core_User::get_users( 'active', $per_page, $page, $user_id, $filter ) );
 }
 
-function friends_get_alphabetically( $user_id, $per_page = false, $page = false, $filter = false ) {
+function friends_get_alphabetically( $user_id, $per_page = 0, $page = 0, $filter = '' ) {
 	return apply_filters( 'friends_get_alphabetically', BP_Core_User::get_users( 'alphabetical', $per_page, $page, $user_id, $filter ) );
 }
 
-function friends_get_newest( $user_id, $per_page = false, $page = false, $filter = false ) {
+function friends_get_newest( $user_id, $per_page = 0, $page = 0, $filter = '' ) {
 	return apply_filters( 'friends_get_newest', BP_Core_User::get_users( 'newest', $per_page, $page, $user_id, $filter ) );
 }
@@ -520,5 +529,5 @@
 }
 
-function friends_get_friends_invite_list( $user_id = false ) {
+function friends_get_friends_invite_list( $user_id = 0 ) {
 	global $bp;
 
@@ -549,5 +558,5 @@
 }
 
-function friends_search_users( $search_terms, $user_id, $pag_num = false, $pag_page = false ) {
+function friends_search_users( $search_terms, $user_id, $pag_num = 0, $pag_page = 0 ) {
 	global $bp;
 
@@ -557,9 +566,8 @@
 		return false;
 
-	for ( $i = 0; $i < count($user_ids); $i++ ) {
+	for ( $i = 0; $i < count( $user_ids ); $i++  )
 		$users[] = new BP_Core_User($user_ids[$i]);
-	}
-
-	return array( 'users' => $users, 'count' => BP_Friends_Friendship::search_users_count($search_terms) );
+
+	return array( 'users' => $users, 'count' => BP_Friends_Friendship::search_users_count( $search_terms ) );
 }
 
@@ -584,14 +592,14 @@
 	BP_Friends_Friendship::delete_all_for_user($user_id);
 
-	/* Remove usermeta */
+	// Remove usermeta
 	delete_user_meta( $user_id, 'total_friend_count' );
 
-	/* Remove friendship requests FROM user */
+	// Remove friendship requests FROM user
 	bp_core_delete_notifications_from_user( $user_id, $bp->friends->id, 'friendship_request' );
 
 	do_action( 'friends_remove_data', $user_id );
 }
-add_action( 'wpmu_delete_user', 'friends_remove_data' );
-add_action( 'delete_user', 'friends_remove_data' );
+add_action( 'wpmu_delete_user',  'friends_remove_data' );
+add_action( 'delete_user',       'friends_remove_data' );
 add_action( 'bp_make_spam_user', 'friends_remove_data' );
 
@@ -608,8 +616,8 @@
 		return false;
 
-	wp_cache_delete( 'friends_friend_ids_' . $friendship->initiator_user_id, 'bp' );
-	wp_cache_delete( 'friends_friend_ids_' . $friendship->friend_user_id, 'bp' );
+	wp_cache_delete( 'friends_friend_ids_' .    $friendship->initiator_user_id, 'bp' );
+	wp_cache_delete( 'friends_friend_ids_' .    $friendship->friend_user_id,    'bp' );
 	wp_cache_delete( 'bp_total_friend_count_' . $friendship->initiator_user_id, 'bp' );
-	wp_cache_delete( 'bp_total_friend_count_' . $friendship->friend_user_id, 'bp' );
+	wp_cache_delete( 'bp_total_friend_count_' . $friendship->friend_user_id,    'bp' );
 }
 
@@ -624,10 +632,10 @@
 // List actions to clear object caches on
 add_action( 'friends_friendship_accepted', 'friends_clear_friend_object_cache' );
-add_action( 'friends_friendship_deleted', 'friends_clear_friend_object_cache' );
+add_action( 'friends_friendship_deleted',  'friends_clear_friend_object_cache' );
 
 // List actions to clear super cached pages on, if super cache is installed
-add_action( 'friends_friendship_rejected', 'bp_core_clear_cache' );
-add_action( 'friends_friendship_accepted', 'bp_core_clear_cache' );
-add_action( 'friends_friendship_deleted', 'bp_core_clear_cache' );
+add_action( 'friends_friendship_rejected',  'bp_core_clear_cache' );
+add_action( 'friends_friendship_accepted',  'bp_core_clear_cache' );
+add_action( 'friends_friendship_deleted',   'bp_core_clear_cache' );
 add_action( 'friends_friendship_requested', 'bp_core_clear_cache' );
 
Index: /trunk/bp-groups.php
===================================================================
--- /trunk/bp-groups.php	(revision 3727)
+++ /trunk/bp-groups.php	(revision 3728)
@@ -1,3 +1,5 @@
 <?php
+
+// Required Files
 require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-classes.php' );
 require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-templatetags.php' );
@@ -14,19 +16,25 @@
 	global $bp;
 
+	// Define a slug, if necessary
 	if ( !defined( 'BP_GROUPS_SLUG' ) )
-		define ( 'BP_GROUPS_SLUG', $bp->pages->groups->slug );
-
-	/* For internal identification */
-	$bp->groups->id = 'groups';
-	$bp->groups->name = $bp->pages->groups->name;
-	$bp->groups->slug = BP_GROUPS_SLUG;
-
+		define ( 'BP_GROUPS_SLUG', bp_core_component_slug_from_root_slug( $bp->pages->groups->slug ) );
+
+	// For internal identification
+	$bp->groups->id        = 'groups';
+	$bp->groups->name      = $bp->pages->groups->name;
+
+	// Slugs
+	$bp->groups->slug      = BP_GROUPS_SLUG;
+	$bp->groups->root_slug = $bp->pages->groups->slug;
+
+	// Tables
 	$bp->groups->table_name           = $bp->table_prefix . 'bp_groups';
 	$bp->groups->table_name_members   = $bp->table_prefix . 'bp_groups_members';
 	$bp->groups->table_name_groupmeta = $bp->table_prefix . 'bp_groups_groupmeta';
 
+	// Notifications
 	$bp->groups->format_notification_function = 'groups_format_notifications';
 
-	/* Register this in the active components array */
+	// Register this in the active components array
 	$bp->active_components[$bp->groups->slug] = $bp->groups->id;
 
@@ -34,7 +42,7 @@
 
 	$bp->groups->group_creation_steps = apply_filters( 'groups_create_group_steps', array(
-		'group-details' => array( 'name' => __( 'Details', 'buddypress' ), 'position' => 0 ),
+		'group-details'  => array( 'name' => __( 'Details', 'buddypress' ), 'position' => 0 ),
 		'group-settings' => array( 'name' => __( 'Settings', 'buddypress' ), 'position' => 10 ),
-		'group-avatar' => array( 'name' => __( 'Avatar', 'buddypress' ), 'position' => 20 ),
+		'group-avatar'   => array( 'name' => __( 'Avatar', 'buddypress' ), 'position' => 20 ),
 	) );
 
@@ -48,5 +56,5 @@
 
 	// The default text for the groups directory search box
-        $bp->default_search_strings[$bp->groups->slug] = __( 'Search Groups...', 'buddypress' );
+	$bp->default_search_strings[$bp->groups->slug] = __( 'Search Groups...', 'buddypress' );
 
 	do_action( 'groups_setup_globals' );
@@ -57,11 +65,11 @@
 	global $bp;
 
-	if ( $bp->current_component == $bp->groups->slug && $group_id = BP_Groups_Group::group_exists($bp->current_action) ) {
-
-		/* This is a single group page. */
+	if ( bp_is_current_component( $bp->groups->slug ) && $group_id = BP_Groups_Group::group_exists($bp->current_action) ) {
+
+		// This is a single group page.
 		$bp->is_single_item = true;
 		$bp->groups->current_group = new BP_Groups_Group( $group_id );
 
-		/* Using "item" not "group" for generic support in other components. */
+		// Using "item" not "group" for generic support in other components.
 		if ( is_super_admin() )
 			$bp->is_item_admin = 1;
@@ -69,25 +77,25 @@
 			$bp->is_item_admin = groups_is_user_admin( $bp->loggedin_user->id, $bp->groups->current_group->id );
 
-		/* If the user is not an admin, check if they are a moderator */
+		// If the user is not an admin, check if they are a moderator
 		if ( !$bp->is_item_admin )
 			$bp->is_item_mod = groups_is_user_mod( $bp->loggedin_user->id, $bp->groups->current_group->id );
 
-		/* Is the logged in user a member of the group? */
+		// Is the logged in user a member of the group?
 		$bp->groups->current_group->is_user_member = ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) ? true : false;
 
-		/* Should this group be visible to the logged in user? */
+		// Should this group be visible to the logged in user?
 		$bp->groups->current_group->is_group_visible_to_member = ( 'public' == $bp->groups->current_group->status || $bp->groups->current_group->is_user_member ) ? true : false;
 	}
 
-	/* Add 'Groups' to the main navigation */
-	bp_core_new_nav_item( array( 'name' => sprintf( __( 'Groups <span>(%d)</span>', 'buddypress' ), groups_total_groups_for_user() ), 'slug' => $bp->groups->name, 'position' => 70, 'screen_function' => 'groups_screen_my_groups', 'default_subnav_slug' => 'my-groups', 'item_css_id' => $bp->groups->id ) );
-
-	$groups_link = $bp->loggedin_user->domain . $bp->groups->name . '/';
-
-	/* Add the subnav items to the groups nav item */
-	bp_core_new_subnav_item( array( 'name' => __( 'My Groups', 'buddypress' ), 'slug' => 'my-groups', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->name, 'screen_function' => 'groups_screen_my_groups', 'position' => 10, 'item_css_id' => 'groups-my-groups' ) );
-	bp_core_new_subnav_item( array( 'name' => __( 'Invites', 'buddypress' ), 'slug' => 'invites', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->name, 'screen_function' => 'groups_screen_group_invites', 'position' => 30, 'user_has_access' => bp_is_my_profile() ) );
-
-	if ( $bp->current_component == $bp->groups->slug ) {
+	// Add 'Groups' to the main navigation
+	bp_core_new_nav_item( array( 'name' => sprintf( __( 'Groups <span>(%d)</span>', 'buddypress' ), groups_total_groups_for_user() ), 'slug' => $bp->groups->slug, 'position' => 70, 'screen_function' => 'groups_screen_my_groups', 'default_subnav_slug' => 'my-groups', 'item_css_id' => $bp->groups->id ) );
+
+	$groups_link = $bp->loggedin_user->domain . $bp->groups->slug . '/';
+
+	// Add the subnav items to the groups nav item
+	bp_core_new_subnav_item( array( 'name' => __( 'My Groups', 'buddypress' ), 'slug' => 'my-groups', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_my_groups',     'position' => 10, 'item_css_id'     => 'groups-my-groups' ) );
+	bp_core_new_subnav_item( array( 'name' => __( 'Invites',   'buddypress' ), 'slug' => 'invites',   'parent_url' => $groups_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_invites', 'position' => 30, 'user_has_access' => bp_is_my_profile() ) );
+
+	if ( bp_is_current_component( $bp->groups->slug ) ) {
 
 		if ( bp_is_my_profile() && !$bp->is_single_item ) {
@@ -104,9 +112,9 @@
 			// group navigation menu using the $bp->groups->current_group global.
 
-			/* When in a single group, the first action is bumped down one because of the
-			   group name, so we need to adjust this and set the group name to current_item. */
-			$bp->current_item = isset( $bp->current_action ) ? $bp->current_action : false;
+			// When in a single group, the first action is bumped down one because of the
+			// group name, so we need to adjust this and set the group name to current_item.
+			$bp->current_item   = isset( $bp->current_action )      ? $bp->current_action      : false;
 			$bp->current_action = isset( $bp->action_variables[0] ) ? $bp->action_variables[0] : false;
-			array_shift($bp->action_variables);
+			array_shift( $bp->action_variables );
 
 			$bp->bp_options_title = $bp->groups->current_group->name;
@@ -115,5 +123,5 @@
 				$bp->bp_options_avatar = '<img src="' . esc_attr( $group->avatar_full ) . '" class="avatar" alt="' . esc_attr( $group->name ) . '" />';
 
-			$group_link = $bp->root_domain . '/' . $bp->groups->slug . '/' . $bp->groups->current_group->slug . '/';
+			$group_link = $bp->root_domain . '/' . $bp->groups->root_slug . '/' . $bp->groups->current_group->slug . '/';
 
 			// If this is a private or hidden group, does the user have access?
@@ -127,29 +135,30 @@
 			}
 
-			/* Reset the existing subnav items */
-			bp_core_reset_subnav_items($bp->groups->slug);
-
-			/* Add a new default subnav item for when the groups nav is selected. */
-			bp_core_new_nav_default( array( 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_home', 'subnav_slug' => 'home' ) );
-
-			/* Add the "Home" subnav item, as this will always be present */
-			bp_core_new_subnav_item( array( 'name' => __( 'Home', 'buddypress' ), 'slug' => 'home', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_home', 'position' => 10, 'item_css_id' => 'home' ) );
-
-			/* If the user is a group mod or more, then show the group admin nav item */
+			// Reset the existing subnav items
+			bp_core_reset_subnav_items( $bp->groups->root_slug );
+
+			// Add a new default subnav item for when the groups nav is selected.
+			bp_core_new_nav_default( array( 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_home', 'subnav_slug' => 'home' ) );
+
+			// Add the "Home" subnav item, as this will always be present
+			bp_core_new_subnav_item( array( 'name' => __( 'Home', 'buddypress' ), 'slug' => 'home', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_home', 'position' => 10, 'item_css_id' => 'home' ) );
+
+			// If the user is a group mod or more, then show the group admin nav item
 			if ( $bp->is_item_mod || $bp->is_item_admin )
-				bp_core_new_subnav_item( array( 'name' => __( 'Admin', 'buddypress' ), 'slug' => 'admin', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_admin', 'position' => 20, 'user_has_access' => ( $bp->is_item_admin + (int)$bp->is_item_mod ), 'item_css_id' => 'admin' ) );
+				bp_core_new_subnav_item( array( 'name' => __( 'Admin', 'buddypress' ), 'slug' => 'admin', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_admin', 'position' => 20, 'user_has_access' => ( $bp->is_item_admin + (int)$bp->is_item_mod ), 'item_css_id' => 'admin' ) );
 
 			// If this is a private group, and the user is not a member, show a "Request Membership" nav item.
 			if ( !is_super_admin() && is_user_logged_in() && !$bp->groups->current_group->is_user_member && !groups_check_for_membership_request( $bp->loggedin_user->id, $bp->groups->current_group->id ) && $bp->groups->current_group->status == 'private' )
-				bp_core_new_subnav_item( array( 'name' => __( 'Request Membership', 'buddypress' ), 'slug' => 'request-membership', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_request_membership', 'position' => 30 ) );
-
-			if ( $bp->groups->current_group->enable_forum && function_exists('bp_forums_setup') )
-				bp_core_new_subnav_item( array( 'name' => __( 'Forum', 'buddypress' ), 'slug' => 'forum', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_forum', 'position' => 40, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'forums' ) );
-
-			bp_core_new_subnav_item( array( 'name' => sprintf( __( 'Members (%s)', 'buddypress' ), number_format( $bp->groups->current_group->total_member_count ) ), 'slug' => 'members', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_members', 'position' => 60, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'members'  ) );
+				bp_core_new_subnav_item( array( 'name' => __( 'Request Membership', 'buddypress' ), 'slug' => 'request-membership', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_request_membership', 'position' => 30 ) );
+
+			// Forums are enabled and turned on
+			if ( $bp->groups->current_group->enable_forum && function_exists( 'bp_forums_setup' ) )
+				bp_core_new_subnav_item( array( 'name' => __( 'Forum', 'buddypress' ), 'slug' => 'forum', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_forum', 'position' => 40, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'forums' ) );
+
+			bp_core_new_subnav_item( array( 'name' => sprintf( __( 'Members (%s)', 'buddypress' ), number_format( $bp->groups->current_group->total_member_count ) ), 'slug' => 'members', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_members', 'position' => 60, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'members'  ) );
 
 			if ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
 				if ( bp_is_active('friends') )
-					bp_core_new_subnav_item( array( 'name' => __( 'Send Invites', 'buddypress' ), 'slug' => 'send-invites', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_invite', 'item_css_id' => 'invite', 'position' => 70, 'user_has_access' => $bp->groups->current_group->user_has_access ) );
+					bp_core_new_subnav_item( array( 'name' => __( 'Send Invites', 'buddypress' ), 'slug' => 'send-invites', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_invite', 'item_css_id' => 'invite', 'position' => 70, 'user_has_access' => $bp->groups->current_group->user_has_access ) );
 			}
 		}
@@ -165,6 +174,6 @@
 function groups_directory_groups_setup() {
 	global $bp;
-
-	if ( $bp->current_component == $bp->groups->slug && empty( $bp->current_action ) && empty( $bp->current_item ) ) {
+	
+	if ( bp_is_current_component( $bp->groups->slug ) && empty( $bp->current_action ) && empty( $bp->current_item ) ) {
 		$bp->is_directory = true;
 
@@ -181,8 +190,8 @@
 		return false;
 
-	/* Don't show this menu to non site admins or if you're viewing your own profile */
+	// Don't show this menu to non site admins or if you're viewing your own profile
 	if ( !is_super_admin() )
-		return false;
-	?>
+		return false; ?>
+
 	<li id="bp-adminbar-adminoptions-menu">
 		<a href=""><?php _e( 'Admin Options', 'buddypress' ) ?></a>
@@ -192,10 +201,11 @@
 
 			<?php do_action( 'groups_adminbar_menu_items' ) ?>
+
 		</ul>
 	</li>
+
 	<?php
 }
 add_action( 'bp_adminbar_menus', 'groups_setup_adminbar_menu', 20 );
-
 
 /********************************************************************************
@@ -210,10 +220,10 @@
 	global $bp;
 
-	if ( isset($_GET['n']) ) {
-		// Delete group request notifications for the user
+	// Delete group request notifications for the user
+	if ( isset( $_GET['n'] ) ) {
 		bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_accepted' );
 		bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_rejected' );
-		bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_mod' );
-		bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_admin' );
+		bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_mod'      );
+		bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_admin'    );
 	}
 
@@ -231,5 +241,5 @@
 
 	if ( isset( $bp->action_variables ) && in_array( 'accept', (array)$bp->action_variables ) && is_numeric( $group_id ) ) {
-		/* Check the nonce */
+		// Check the nonce
 		if ( !check_admin_referer( 'groups_accept_invite' ) )
 			return false;
@@ -240,10 +250,10 @@
 			bp_core_add_message( __('Group invite accepted', 'buddypress') );
 
-			/* Record this in activity streams */
+			// Record this in activity streams
 			$group = new BP_Groups_Group( $group_id );
 
 			groups_record_activity( array(
-				'action' => apply_filters( 'groups_activity_accepted_invite_action', sprintf( __( '%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . esc_attr( $group->name ) . '</a>' ), $bp->loggedin_user->id, &$group ),
-				'type' => 'joined_group',
+				'action'  => apply_filters( 'groups_activity_accepted_invite_action', sprintf( __( '%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . esc_attr( $group->name ) . '</a>' ), $bp->loggedin_user->id, &$group ),
+				'type'    => 'joined_group',
 				'item_id' => $group->id
 			) );
@@ -253,5 +263,5 @@
 
 	} elseif ( isset( $bp->action_variables ) && in_array( 'reject', (array)$bp->action_variables ) && is_numeric( $group_id ) ) {
-		/* Check the nonce */
+		// Check the nonce
 		if ( !check_admin_referer( 'groups_reject_invite' ) )
 			return false;
@@ -277,10 +287,9 @@
 
 	if ( $bp->is_single_item ) {
-		if ( isset($_GET['n']) ) {
-			// Delete group request notifications for the user
+		if ( isset( $_GET['n'] ) ) {
 			bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_accepted' );
 			bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_rejected' );
-			bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_mod' );
-			bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_admin' );
+			bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_mod'      );
+			bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_admin'    );
 		}
 
@@ -296,10 +305,10 @@
 	if ( $bp->is_single_item && $bp->groups->current_group->user_has_access ) {
 
-		/* Fetch the details we need */
-		$topic_slug = isset( $bp->action_variables[1] ) ? $bp->action_variables[1] : false;
-		$topic_id = bp_forums_get_topic_id_from_slug( $topic_slug );
-		$forum_id = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' );
-
+		// Fetch the details we need 
+		$topic_slug     = isset( $bp->action_variables[1] ) ? $bp->action_variables[1] : false;
+		$topic_id       = bp_forums_get_topic_id_from_slug( $topic_slug );
+		$forum_id       = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' );
 		$user_is_banned = false;
+
 		if ( !is_super_admin() && groups_is_user_banned( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
 			$user_is_banned = true;
@@ -307,14 +316,14 @@
 		if ( $topic_slug && $topic_id ) {
 
-			/* Posting a reply */
+			// Posting a reply
 			if ( !$user_is_banned && !isset( $bp->action_variables[2] ) && isset( $_POST['submit_reply'] ) ) {
-				/* Check the nonce */
+				// Check the nonce
 				check_admin_referer( 'bp_forums_new_reply' );
 
-				/* Auto join this user if they are not yet a member of this group */
+				// Auto join this user if they are not yet a member of this group
 				if ( $bp->groups->auto_join && !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
 					groups_join_group( $bp->groups->current_group->id, $bp->loggedin_user->id );
 
-                                $topic_page = isset( $_GET['topic_page'] ) ? $_GET['topic_page'] : false;
+				$topic_page = isset( $_GET['topic_page'] ) ? $_GET['topic_page'] : false;
 
 				if ( !$post_id = groups_new_group_forum_post( $_POST['reply_text'], $topic_id, $topic_page ) )
@@ -329,7 +338,7 @@
 			}
 
-			/* Sticky a topic */
+			// Sticky a topic
 			else if ( isset( $bp->action_variables[2] ) && 'stick' == $bp->action_variables[2] && ( isset( $bp->is_item_admin ) || isset( $bp->is_item_mod ) ) ) {
-				/* Check the nonce */
+				// Check the nonce
 				check_admin_referer( 'bp_forums_stick_topic' );
 
@@ -343,7 +352,7 @@
 			}
 
-			/* Un-Sticky a topic */
+			// Un-Sticky a topic
 			else if ( isset( $bp->action_variables[2] ) && 'unstick' == $bp->action_variables[2] && ( isset( $bp->is_item_admin ) || isset( $bp->is_item_mod ) ) ) {
-				/* Check the nonce */
+				// Check the nonce
 				check_admin_referer( 'bp_forums_unstick_topic' );
 
@@ -357,7 +366,7 @@
 			}
 
-			/* Close a topic */
+			// Close a topic
 			else if ( isset( $bp->action_variables[2] ) && 'close' == $bp->action_variables[2] && ( isset( $bp->is_item_admin ) || isset( $bp->is_item_mod ) ) ) {
-				/* Check the nonce */
+				// Check the nonce
 				check_admin_referer( 'bp_forums_close_topic' );
 
@@ -371,7 +380,7 @@
 			}
 
-			/* Open a topic */
+			// Open a topic
 			else if ( isset( $bp->action_variables[2] ) && 'open' == $bp->action_variables[2] && ( isset( $bp->is_item_admin ) || isset( $bp->is_item_mod ) ) ) {
-				/* Check the nonce */
+				// Check the nonce
 				check_admin_referer( 'bp_forums_open_topic' );
 
@@ -385,7 +394,7 @@
 			}
 
-			/* Delete a topic */
+			// Delete a topic
 			else if ( !$user_is_banned && isset( $bp->action_variables[2] ) && 'delete' == $bp->action_variables[2] && empty( $bp->action_variables[3] ) ) {
-				/* Fetch the topic */
+				// Fetch the topic
 				$topic = bp_forums_get_topic_details( $topic_id );
 
@@ -394,5 +403,5 @@
 					bp_core_redirect( wp_get_referer() );
 
-				/* Check the nonce */
+				// Check the nonce
 				check_admin_referer( 'bp_forums_delete_topic' );
 
@@ -407,15 +416,15 @@
 			}
 
-			/* Editing a topic */
+			// Editing a topic
 			else if ( !$user_is_banned && isset( $bp->action_variables[2] ) && 'edit' == $bp->action_variables[2] && empty( $bp->action_variables[3] ) ) {
-				/* Fetch the topic */
+				// Fetch the topic
 				$topic = bp_forums_get_topic_details( $topic_id );
 
-				/* Check the logged in user can edit this topic */
+				// Check the logged in user can edit this topic
 				if ( !$bp->is_item_admin && !$bp->is_item_mod && (int)$bp->loggedin_user->id != (int)$topic->topic_poster )
 					bp_core_redirect( wp_get_referer() );
 
 				if ( isset( $_POST['save_changes'] ) ) {
-					/* Check the nonce */
+					// Check the nonce
 					check_admin_referer( 'bp_forums_edit_topic' );
 
@@ -432,14 +441,14 @@
 			}
 
-			/* Delete a post */
+			// Delete a post
 			else if ( !$user_is_banned && isset( $bp->action_variables[2] ) && 'delete' == $bp->action_variables[2] && isset( $bp->action_variables[4] ) && $post_id = $bp->action_variables[4] ) {
-				/* Fetch the post */
+				// Fetch the post
 				$post = bp_forums_get_post( $post_id );
 
-				/* Check the logged in user can edit this topic */
+				// Check the logged in user can edit this topic
 				if ( !$bp->is_item_admin && !$bp->is_item_mod && (int)$bp->loggedin_user->id != (int)$post->poster_id )
 					bp_core_redirect( wp_get_referer() );
 
-				/* Check the nonce */
+				// Check the nonce
 				check_admin_referer( 'bp_forums_delete_post' );
 
@@ -455,15 +464,15 @@
 			}
 
-			/* Editing a post */
+			// Editing a post
 			else if ( !$user_is_banned && isset( $bp->action_variables[2] ) && 'edit' == $bp->action_variables[2] && isset( $bp->action_variables[4] ) && $post_id = $bp->action_variables[4] ) {
-				/* Fetch the post */
+				// Fetch the post
 				$post = bp_forums_get_post( $bp->action_variables[4] );
 
-				/* Check the logged in user can edit this topic */
+				// Check the logged in user can edit this topic
 				if ( !$bp->is_item_admin && !$bp->is_item_mod && (int)$bp->loggedin_user->id != (int)$post->poster_id )
 					bp_core_redirect( wp_get_referer() );
 
 				if ( isset( $_POST['save_changes'] ) ) {
-					/* Check the nonce */
+					// Check the nonce
 					check_admin_referer( 'bp_forums_edit_post' );
 
@@ -483,5 +492,5 @@
 			}
 
-			/* Standard topic display */
+			// Standard topic display
 			else {
 				if ( $user_is_banned )
@@ -492,7 +501,7 @@
 
 		} else {
-			/* Posting a topic */
+			// Posting a topic
 			if ( isset( $_POST['submit_topic'] ) && function_exists( 'bp_forums_new_topic') ) {
-				/* Check the nonce */
+				// Check the nonce
 				check_admin_referer( 'bp_forums_new_topic' );
 
@@ -578,5 +587,5 @@
 		// If the user has submitted a request, send it.
 		if ( isset( $_POST['group-request-send']) ) {
-			/* Check the nonce first. */
+			// Check the nonce
 			if ( !check_admin_referer( 'groups_request_membership' ) )
 				return false;
@@ -599,5 +608,5 @@
 	global $bp;
 
-	if ( $bp->current_component != $bp->groups->slug || $bp->current_action != $bp->activity->slug || empty( $bp->action_variables[0] ) )
+	if ( !bp_is_current_component( $bp->groups->slug ) || $bp->current_action != $bp->activity->slug || empty( $bp->action_variables[0] ) )
 		return false;
 
@@ -611,5 +620,5 @@
 	global $bp;
 
-	if ( $bp->current_component != BP_GROUPS_SLUG || 'admin' != $bp->current_action )
+	if ( !bp_is_current_component( BP_GROUPS_SLUG ) || 'admin' != $bp->current_action )
 		return false;
 
@@ -623,5 +632,5 @@
 	global $bp;
 
-	if ( $bp->current_component == $bp->groups->slug && 'edit-details' == $bp->action_variables[0] ) {
+	if ( bp_is_current_component( $bp->groups->slug ) && 'edit-details' == $bp->action_variables[0] ) {
 
 		if ( $bp->is_item_admin || $bp->is_item_mod  ) {
@@ -629,5 +638,5 @@
 			// If the edit form has been submitted, save the edited details
 			if ( isset( $_POST['save'] ) ) {
-				/* Check the nonce first. */
+				// Check the nonce
 				if ( !check_admin_referer( 'groups_edit_group_details' ) )
 					return false;
@@ -655,5 +664,5 @@
 	global $bp;
 
-	if ( $bp->current_component == $bp->groups->slug && 'group-settings' == $bp->action_variables[0] ) {
+	if ( bp_is_current_component( $bp->groups->slug ) && 'group-settings' == $bp->action_variables[0] ) {
 
 		if ( !$bp->is_item_admin )
@@ -667,5 +676,5 @@
 			$status = ( in_array( $_POST['group-status'], (array)$allowed_status ) ) ? $_POST['group-status'] : 'public';
 
-			/* Check the nonce first. */
+			// Check the nonce
 			if ( !check_admin_referer( 'groups_edit_group_settings' ) )
 				return false;
@@ -692,13 +701,13 @@
 	global $bp;
 
-	if ( $bp->current_component == $bp->groups->slug && 'group-avatar' == $bp->action_variables[0] ) {
+	if ( bp_is_current_component( $bp->groups->slug ) && 'group-avatar' == $bp->action_variables[0] ) {
 
 		if ( !$bp->is_item_admin )
 			return false;
 
-		/* If the group admin has deleted the admin avatar */
+		// If the group admin has deleted the admin avatar
 		if ( 'delete' == $bp->action_variables[1] ) {
 
-			/* Check the nonce */
+			// Check the nonce
 			check_admin_referer( 'bp_group_avatar_delete' );
 
@@ -714,12 +723,12 @@
 		if ( !empty( $_FILES ) ) {
 
-			/* Check the nonce */
+			// Check the nonce
 			check_admin_referer( 'bp_avatar_upload' );
 
-			/* Pass the file to the avatar upload handler */
+			// Pass the file to the avatar upload handler
 			if ( bp_core_avatar_handle_upload( $_FILES, 'groups_avatar_upload_dir' ) ) {
 				$bp->avatar_admin->step = 'crop-image';
 
-				/* Make sure we include the jQuery jCrop file for image cropping */
+				// Make sure we include the jQuery jCrop file for image cropping
 				add_action( 'wp_print_scripts', 'bp_core_add_jquery_cropper' );
 			}
@@ -727,8 +736,8 @@
 		}
 
-		/* If the image cropping is done, crop the image and save a full/thumb version */
+		// If the image cropping is done, crop the image and save a full/thumb version
 		if ( isset( $_POST['avatar-crop-submit'] ) ) {
 
-			/* Check the nonce */
+			// Check the nonce
 			check_admin_referer( 'bp_avatar_cropstore' );
 
@@ -750,5 +759,5 @@
 	global $bp;
 
-	if ( $bp->current_component == $bp->groups->slug && 'manage-members' == $bp->action_variables[0] ) {
+	if ( bp_is_current_component( $bp->groups->slug ) && 'manage-members' == $bp->action_variables[0] ) {
 
 		if ( !$bp->is_item_admin )
@@ -856,7 +865,7 @@
 	global $bp;
 
-	if ( $bp->current_component == $bp->groups->slug && 'membership-requests' == $bp->action_variables[0] ) {
-
-		/* Ask for a login if the user is coming here via an email notification */
+	if ( bp_is_current_component( $bp->groups->slug ) && 'membership-requests' == $bp->action_variables[0] ) {
+
+		// Ask for a login if the user is coming here via an email notification
 		if ( !is_user_logged_in() )
 			bp_core_redirect( site_url( 'wp-login.php?redirect_to=' . $bp->root_domain . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/membership-requests/' ) );
@@ -874,5 +883,5 @@
 			if ( 'accept' == $request_action && is_numeric($membership_id) ) {
 
-				/* Check the nonce first. */
+				// Check the nonce first.
 				if ( !check_admin_referer( 'groups_accept_membership_request' ) )
 					return false;
@@ -914,5 +923,5 @@
 	global $bp;
 
-	if ( $bp->current_component == $bp->groups->slug && 'delete-group' == $bp->action_variables[0] ) {
+	if ( bp_is_current_component( $bp->groups->slug ) && 'delete-group' == $bp->action_variables[0] ) {
 
 		if ( !$bp->is_item_admin && !is_super_admin() )
@@ -920,5 +929,5 @@
 
 		if ( isset( $_REQUEST['delete-group-button'] ) && isset( $_REQUEST['delete-group-understand'] ) ) {
-			/* Check the nonce first. */
+			// Check the nonce first.
 			if ( !check_admin_referer( 'groups_delete_group' ) )
 				return false;
@@ -950,20 +959,17 @@
 	global $bp;
 
-	$group_invite = get_user_meta( $bp->displayed_user->id, 'notification_groups_invite', true );
-	if ( !$group_invite )
-		$group_invite = 'yes';
-
-	$group_update = get_user_meta( $bp->displayed_user->id, 'notification_groups_group_updated', true );
-	if ( !$group_update )
-		$group_update = 'yes';
-
-	$group_promo = get_user_meta( $bp->displayed_user->id, 'notification_groups_admin_promotion', true );
-	if ( !$group_promo )
-		$group_promo = 'yes';
-
-	$group_request = get_user_meta( $bp->displayed_user->id, 'notification_groups_membership_request', true );
-	if ( !$group_request )
+	if ( !$group_invite = get_user_meta( $bp->displayed_user->id, 'notification_groups_invite', true ) )
+		$group_invite  = 'yes';
+
+	if ( !$group_update = get_user_meta( $bp->displayed_user->id, 'notification_groups_group_updated', true ) )
+		$group_update  = 'yes';
+
+	if ( !$group_promo = get_user_meta( $bp->displayed_user->id, 'notification_groups_admin_promotion', true ) )
+		$group_promo   = 'yes';
+
+	if ( !$group_request = get_user_meta( $bp->displayed_user->id, 'notification_groups_membership_request', true ) )
 		$group_request = 'yes';
 ?>
+
 	<table class="notification-settings zebra" id="groups-notification-settings">
 		<thead>
@@ -1003,6 +1009,8 @@
 
 			<?php do_action( 'groups_screen_notification_settings' ); ?>
+
 		</tbody>
 	</table>
+
 <?php
 }
@@ -1021,6 +1029,6 @@
 	global $bp;
 
-	/* If we're not at domain.org/groups/create/ then return false */
-	if ( $bp->current_component != $bp->groups->slug || 'create' != $bp->current_action )
+	// If we're not at domain.org/groups/create/ then return false
+	if ( !bp_is_current_component( $bp->groups->slug ) || 'create' != $bp->current_action )
 		return false;
 
@@ -1028,8 +1036,8 @@
 		return false;
 
-	/* Make sure creation steps are in the right order */
+	// Make sure creation steps are in the right order
 	groups_action_sort_creation_steps();
 
-	/* If no current step is set, reset everything so we can start a fresh group creation */
+	// If no current step is set, reset everything so we can start a fresh group creation
 	if ( !isset( $bp->action_variables[1] ) || !$bp->groups->current_create_step = $bp->action_variables[1] ) {
 
@@ -1041,18 +1049,18 @@
 
 		$reset_steps = true;
-		bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . array_shift( array_keys( $bp->groups->group_creation_steps ) ) . '/' );
-	}
-
-	/* If this is a creation step that is not recognized, just redirect them back to the first screen */
+		bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/step/' . array_shift( array_keys( $bp->groups->group_creation_steps ) ) . '/' );
+	}
+
+	// If this is a creation step that is not recognized, just redirect them back to the first screen
 	if ( $bp->action_variables[1] && !$bp->groups->group_creation_steps[$bp->action_variables[1]] ) {
 		bp_core_add_message( __('There was an error saving group details. Please try again.', 'buddypress'), 'error' );
-		bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/' );
-	}
-
-	/* Fetch the currently completed steps variable */
+		bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/' );
+	}
+
+	// Fetch the currently completed steps variable
 	if ( isset( $_COOKIE['bp_completed_create_steps'] ) && !isset( $reset_steps ) )
 		$bp->groups->completed_create_steps = unserialize( stripslashes( $_COOKIE['bp_completed_create_steps'] ) );
 
-	/* Set the ID of the new group, if it has already been created in a previous step */
+	// Set the ID of the new group, if it has already been created in a previous step
 	if ( isset( $_COOKIE['bp_new_group_id'] ) ) {
 		$bp->groups->new_group_id = $_COOKIE['bp_new_group_id'];
@@ -1060,8 +1068,8 @@
 	}
 
-	/* If the save, upload or skip button is hit, lets calculate what we need to save */
+	// If the save, upload or skip button is hit, lets calculate what we need to save
 	if ( isset( $_POST['save'] ) ) {
 
-		/* Check the nonce */
+		// Check the nonce
 		check_admin_referer( 'groups_create_save_' . $bp->groups->current_create_step );
 
@@ -1069,5 +1077,5 @@
 			if ( empty( $_POST['group-name'] ) || empty( $_POST['group-desc'] ) || !strlen( trim( $_POST['group-name'] ) ) || !strlen( trim( $_POST['group-desc'] ) ) ) {
 				bp_core_add_message( __( 'Please fill in all of the required fields', 'buddypress' ), 'error' );
-				bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step . '/' );
+				bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/step/' . $bp->groups->current_create_step . '/' );
 			}
 
@@ -1076,5 +1084,5 @@
 			if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $new_group_id, 'name' => $_POST['group-name'], 'description' => $_POST['group-desc'], 'slug' => groups_check_slug( sanitize_title( esc_attr( $_POST['group-name'] ) ) ), 'date_created' => bp_core_current_time(), 'status' => 'public' ) ) ) {
 				bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' );
-				bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step . '/' );
+				bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/step/' . $bp->groups->current_create_step . '/' );
 			}
 
@@ -1090,5 +1098,5 @@
 				$group_enable_forum = 0;
 			} else {
-				/* Create the forum if enable_forum = 1 */
+				// Create the forum if enable_forum = 1
 				if ( function_exists( 'bp_forums_setup' ) && '' == groups_get_groupmeta( $bp->groups->new_group_id, 'forum_id' ) ) {
 					groups_new_group_forum();
@@ -1103,11 +1111,10 @@
 			if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'status' => $group_status, 'enable_forum' => $group_enable_forum ) ) ) {
 				bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' );
-				bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step . '/' );
+				bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/step/' . $bp->groups->current_create_step . '/' );
 			}
 		}
 
-		if ( 'group-invites' == $bp->groups->current_create_step ) {
+		if ( 'group-invites' == $bp->groups->current_create_step )
 			groups_send_invites( $bp->loggedin_user->id, $bp->groups->new_group_id );
-		}
 
 		do_action( 'groups_create_group_step_save_' . $bp->groups->current_create_step );
@@ -1123,14 +1130,15 @@
 			$bp->groups->completed_create_steps[] = $bp->groups->current_create_step;
 
-		/* Reset cookie info */
+		// Reset cookie info
 		setcookie( 'bp_new_group_id', $bp->groups->new_group_id, time()+60*60*24, COOKIEPATH );
 		setcookie( 'bp_completed_create_steps', serialize( $bp->groups->completed_create_steps ), time()+60*60*24, COOKIEPATH );
 
-		/* If we have completed all steps and hit done on the final step we can redirect to the completed group */
+		// If we have completed all steps and hit done on the final step we
+		// can redirect to the completed group
 		if ( count( $bp->groups->completed_create_steps ) == count( $bp->groups->group_creation_steps ) && $bp->groups->current_create_step == array_pop( array_keys( $bp->groups->group_creation_steps ) ) ) {
 			unset( $bp->groups->current_create_step );
 			unset( $bp->groups->completed_create_steps );
 
-			/* Once we compelete all steps, record the group creation in the activity stream. */
+			// Once we compelete all steps, record the group creation in the activity stream.
 			groups_record_activity( array(
 				'action' => apply_filters( 'groups_activity_created_group_action', sprintf( __( '%1$s created the group %2$s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . esc_attr( $bp->groups->current_group->name ) . '</a>' ) ),
@@ -1159,25 +1167,25 @@
 			}
 
-			bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . $next_step . '/' );
-		}
-	}
-
-	/* Group avatar is handled separately */
+			bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/step/' . $next_step . '/' );
+		}
+	}
+
+	// Group avatar is handled separately
 	if ( 'group-avatar' == $bp->groups->current_create_step && isset( $_POST['upload'] ) ) {
 		if ( !empty( $_FILES ) && isset( $_POST['upload'] ) ) {
-			/* Normally we would check a nonce here, but the group save nonce is used instead */
-
-			/* Pass the file to the avatar upload handler */
+			// Normally we would check a nonce here, but the group save nonce is used instead
+
+			// Pass the file to the avatar upload handler
 			if ( bp_core_avatar_handle_upload( $_FILES, 'groups_avatar_upload_dir' ) ) {
 				$bp->avatar_admin->step = 'crop-image';
 
-				/* Make sure we include the jQuery jCrop file for image cropping */
+				// Make sure we include the jQuery jCrop file for image cropping
 				add_action( 'wp_print_scripts', 'bp_core_add_jquery_cropper' );
 			}
 		}
 
-		/* If the image cropping is done, crop the image and save a full/thumb version */
+		// If the image cropping is done, crop the image and save a full/thumb version
 		if ( isset( $_POST['avatar-crop-submit'] ) && isset( $_POST['upload'] ) ) {
-			/* Normally we would check a nonce here, but the group save nonce is used instead */
+			// Normally we would check a nonce here, but the group save nonce is used instead
 
 			if ( !bp_core_avatar_handle_crop( array( 'object' => 'group', 'avatar_dir' => 'group-avatars', 'item_id' => $bp->groups->current_group->id, 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h'] ) ) )
@@ -1195,5 +1203,5 @@
 	global $bp;
 
-	if ( !$bp->is_single_item || $bp->current_component != $bp->groups->slug || $bp->current_action != 'join' )
+	if ( !$bp->is_single_item || !bp_is_current_component( $bp->groups->slug ) || $bp->current_action != 'join' )
 		return false;
 
@@ -1230,5 +1238,5 @@
 	global $bp;
 
-	if ( !$bp->is_single_item || $bp->current_component != $bp->groups->slug || $bp->current_action != 'leave-group' )
+	if ( !$bp->is_single_item || !bp_is_current_component( $bp->groups->slug ) || $bp->current_action != 'leave-group' )
 		return false;
 
@@ -1255,5 +1263,5 @@
 	global $bp;
 
-	if ( $bp->current_component != BP_GROUPS_SLUG && $bp->current_action != 'create' )
+	if ( !bp_is_current_component( BP_GROUPS_SLUG ) && $bp->current_action != 'create' )
 		return false;
 
@@ -1268,5 +1276,5 @@
 	}
 
-	/* Sort the steps by their position key */
+	// Sort the steps by their position key
 	ksort($temp);
 	unset($bp->groups->group_creation_steps);
@@ -1279,5 +1287,5 @@
 	global $bp, $wpdb;
 
-	if ( $bp->current_component == $bp->groups->slug && isset( $_GET['random-group'] ) ) {
+	if ( bp_is_current_component( $bp->groups->slug ) && isset( $_GET['random-group'] ) ) {
 		$group = groups_get_groups( array( 'type' => 'random', 'per_page' => 1 ) );
 
@@ -1290,5 +1298,5 @@
 	global $bp, $wp_query;
 
-	if ( !bp_is_active( 'activity' ) || $bp->current_component != $bp->groups->slug || !isset( $bp->groups->current_group ) || $bp->current_action != 'feed' )
+	if ( !bp_is_active( 'activity' ) || !bp_is_current_component( $bp->groups->slug ) || !isset( $bp->groups->current_group ) || $bp->current_action != 'feed' )
 		return false;
 
@@ -1320,8 +1328,8 @@
 		return false;
 
-	bp_activity_set_action( $bp->groups->id, 'created_group', __( 'Created a group', 'buddypress' ) );
-	bp_activity_set_action( $bp->groups->id, 'joined_group', __( 'Joined a group', 'buddypress' ) );
+	bp_activity_set_action( $bp->groups->id, 'created_group',   __( 'Created a group',       'buddypress' ) );
+	bp_activity_set_action( $bp->groups->id, 'joined_group',    __( 'Joined a group',        'buddypress' ) );
 	bp_activity_set_action( $bp->groups->id, 'new_forum_topic', __( 'New group forum topic', 'buddypress' ) );
-	bp_activity_set_action( $bp->groups->id, 'new_forum_post', __( 'New group forum post', 'buddypress' ) );
+	bp_activity_set_action( $bp->groups->id, 'new_forum_post',  __( 'New group forum post',  'buddypress' ) );
 
 	do_action( 'groups_register_activity_actions' );
@@ -1335,5 +1343,5 @@
 		return false;
 
-	/* If the group is not public, hide the activity sitewide. */
+	// If the group is not public, hide the activity sitewide.
 	if ( 'public' == $bp->groups->current_group->status )
 		$hide_sitewide = false;
@@ -1341,16 +1349,16 @@
 		$hide_sitewide = true;
 
-	$defaults = array(
-		'id' => false,
-		'user_id' => $bp->loggedin_user->id,
-		'action' => '',
-		'content' => '',
-		'primary_link' => '',
-		'component' => $bp->groups->id,
-		'type' => false,
-		'item_id' => false,
+	$defaults = array (
+		'id'                => false,
+		'user_id'           => $bp->loggedin_user->id,
+		'action'            => '',
+		'content'           => '',
+		'primary_link'      => '',
+		'component'         => $bp->groups->id,
+		'type'              => false,
+		'item_id'           => false,
 		'secondary_item_id' => false,
-		'recorded_time' => bp_core_current_time(),
-		'hide_sitewide' => $hide_sitewide
+		'recorded_time'     => bp_core_current_time(),
+		'hide_sitewide'     => $hide_sitewide
 	);
 
@@ -1361,5 +1369,5 @@
 }
 
-function groups_update_last_activity( $group_id = false ) {
+function groups_update_last_activity( $group_id = 0 ) {
 	global $bp;
 
@@ -1395,5 +1403,5 @@
 				return apply_filters( 'bp_groups_single_new_membership_request_notification', '<a href="' . $group_link . 'admin/membership-requests/?n=1" title="' . sprintf( __( '%s requests group membership', 'buddypress' ), $user_fullname ) . '">' . sprintf( __( '%1$s requests membership for the group "%2$s"', 'buddypress' ), $user_fullname, $group->name ) . '</a>', $group_link, $user_fullname, $group->name );
 			}
-		break;
+			break;
 
 		case 'membership_request_accepted':
@@ -1408,5 +1416,5 @@
 				return apply_filters( 'bp_groups_single_membership_request_accepted_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __( 'Membership for group "%s" accepted', 'buddypress' ), $group->name ) . '</a>', $group_link, $group->name );
 
-		break;
+			break;
 
 		case 'membership_request_rejected':
@@ -1421,5 +1429,5 @@
 				return apply_filters( 'bp_groups_single_membership_request_rejected_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __( 'Membership for group "%s" rejected', 'buddypress' ), $group->name ) . '</a>', $group_link, $group->name );
 
-		break;
+			break;
 
 		case 'member_promoted_to_admin':
@@ -1434,5 +1442,5 @@
 				return apply_filters( 'bp_groups_single_member_promoted_to_admin_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __( 'You were promoted to an admin in the group %s', 'buddypress' ), $group->name ) . '</a>', $group_link, $group->name );
 
-		break;
+			break;
 
 		case 'member_promoted_to_mod':
@@ -1447,5 +1455,5 @@
 				return apply_filters( 'bp_groups_single_member_promoted_to_mod_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __( 'You were promoted to a mod in the group %s', 'buddypress' ), $group->name ) . '</a>', $group_link, $group->name );
 
-		break;
+			break;
 
 		case 'group_invite':
@@ -1460,5 +1468,5 @@
 				return apply_filters( 'bp_groups_single_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites/?n=1" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __( 'You have an invitation to the group: %s', 'buddypress' ), $group->name ) . '</a>', $group->name );
 
-		break;
+			break;
 	}
 
@@ -1480,5 +1488,5 @@
 function groups_get_group( $args = '' ) {
 	$defaults = array(
-		'group_id' => false,
+		'group_id'   => false,
 		'load_users' => false
 	);
@@ -1544,12 +1552,12 @@
 		return false;
 
+	// If this is a new group, set up the creator as the first member and admin
 	if ( !$group_id ) {
-		// If this is a new group, set up the creator as the first member and admin
-		$member = new BP_Groups_Member;
-		$member->group_id = $group->id;
-		$member->user_id = $group->creator_id;
-		$member->is_admin = 1;
-		$member->user_title = __( 'Group Admin', 'buddypress' );
-		$member->is_confirmed = 1;
+		$member                = new BP_Groups_Member;
+		$member->group_id      = $group->id;
+		$member->user_id       = $group->creator_id;
+		$member->is_admin      = 1;
+		$member->user_title    = __( 'Group Admin', 'buddypress' );
+		$member->is_confirmed  = 1;
 		$member->date_modified = bp_core_current_time();
 
@@ -1572,6 +1580,6 @@
 		return false;
 
-	$group = new BP_Groups_Group( $group_id );
-	$group->name = $group_name;
+	$group              = new BP_Groups_Group( $group_id );
+	$group->name        = $group_name;
 	$group->description = $group_desc;
 
@@ -1602,5 +1610,5 @@
 		groups_accept_all_pending_membership_requests( $group->id );
 
-	/* Now update the status */
+	// Now update the status
 	$group->status = $status;
 
@@ -1608,5 +1616,5 @@
 		return false;
 
-	/* If forums have been enabled, and a forum does not yet exist, we need to create one. */
+	// If forums have been enabled, and a forum does not yet exist, we need to create one.
 	if ( $group->enable_forum ) {
 		if ( function_exists( 'bp_forums_setup' ) && '' == groups_get_groupmeta( $group->id, 'forum_id' ) ) {
@@ -1675,7 +1683,6 @@
 		$slug = substr( $slug, 2, strlen( $slug ) - 2 );
 
-	if ( in_array( $slug, (array)$bp->groups->forbidden_names ) ) {
+	if ( in_array( $slug, (array)$bp->groups->forbidden_names ) )
 		$slug = $slug . '-' . rand();
-	}
 
 	if ( BP_Groups_Group::check_slug( $slug ) ) {
@@ -1696,5 +1703,5 @@
 /*** User Actions ***************************************************************/
 
-function groups_leave_group( $group_id, $user_id = false ) {
+function groups_leave_group( $group_id, $user_id = 0 ) {
 	global $bp;
 
@@ -1702,5 +1709,5 @@
 		$user_id = $bp->loggedin_user->id;
 
-	/* Don't let single admins leave the group. */
+	// Don't let single admins leave the group.
 	if ( count( groups_get_group_admins( $group_id ) ) < 2 ) {
 		if ( groups_is_user_admin( $user_id, $group_id ) ) {
@@ -1716,12 +1723,14 @@
 		return false;
 
-	/* Modify group member count */
+	// Modify group member count
 	groups_update_groupmeta( $group_id, 'total_member_count', (int) groups_get_groupmeta( $group_id, 'total_member_count') - 1 );
 
-	/* Modify user's group memberhip count */
+	// Modify user's group memberhip count
 	update_user_meta( $user_id, 'total_group_count', (int) get_user_meta( $user_id, 'total_group_count', true ) - 1 );
 
-	/* If the user joined this group less than five minutes ago, remove the joined_group activity so
-	 * users cannot flood the activity stream by joining/leaving the group in quick succession.
+	/**
+	 * If the user joined this group less than five minutes ago, remove the
+	 * joined_group activity so users cannot flood the activity stream by
+	 * joining/leaving the group in quick succession.
 	 */
 	if ( function_exists( 'bp_activity_delete' ) && gmmktime() <= strtotime( '+5 minutes', (int)strtotime( $membership->date_modified ) ) )
@@ -1735,5 +1744,5 @@
 }
 
-function groups_join_group( $group_id, $user_id = false ) {
+function groups_join_group( $group_id, $user_id = 0 ) {
 	global $bp;
 
@@ -1753,12 +1762,12 @@
 		return true;
 
-	$new_member = new BP_Groups_Member;
-	$new_member->group_id = $group_id;
-	$new_member->user_id = $user_id;
-	$new_member->inviter_id = 0;
-	$new_member->is_admin = 0;
-	$new_member->user_title = '';
+	$new_member                = new BP_Groups_Member;
+	$new_member->group_id      = $group_id;
+	$new_member->user_id       = $user_id;
+	$new_member->inviter_id    = 0;
+	$new_member->is_admin      = 0;
+	$new_member->user_title    = '';
 	$new_member->date_modified = bp_core_current_time();
-	$new_member->is_confirmed = 1;
+	$new_member->is_confirmed  = 1;
 
 	if ( !$new_member->save() )
@@ -1772,6 +1781,6 @@
 	// Record this in activity streams
 	groups_record_activity( array(
-		'action' => apply_filters( 'groups_activity_joined_group', sprintf( __( '%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . esc_attr( bp_get_group_name( $group ) ) . '</a>' ) ),
-		'type' => 'joined_group',
+		'action'  => apply_filters( 'groups_activity_joined_group', sprintf( __( '%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . esc_attr( bp_get_group_name( $group ) ) . '</a>' ) ),
+		'type'    => 'joined_group',
 		'item_id' => $group_id,
 		'user_id' => $user_id
@@ -1815,14 +1824,14 @@
 
 	$defaults = array(
-		'type' => 'active', // active, newest, alphabetical, random, popular, most-forum-topics or most-forum-posts
-		'user_id' => false, // Pass a user_id to limit to only groups that this user is a member of
-		'include' => false, // Only include these specific groups (group_ids)
-		'exclude' => false, // Do not include these specific groups (group_ids)
-		'search_terms' => false, // Limit to groups that match these search terms
-		'show_hidden' => false, // Show hidden groups to non-admins
-
-		'per_page' => 20, // The number of results to return per page
-		'page' => 1, // The page to return if limiting per page
-		'populate_extras' => true, // Fetch meta such as is_banned and is_member
+		'type'            => 'active', // active, newest, alphabetical, random, popular, most-forum-topics or most-forum-posts
+		'user_id'         => false,    // Pass a user_id to limit to only groups that this user is a member of
+		'include'         => false,    // Only include these specific groups (group_ids)
+		'exclude'         => false,    // Do not include these specific groups (group_ids)
+		'search_terms'    => false,    // Limit to groups that match these search terms
+		'show_hidden'     => false,    // Show hidden groups to non-admins
+
+		'per_page'        => 20,       // The number of results to return per page
+		'page'            => 1,        // The page to return if limiting per page
+		'populate_extras' => true,     // Fetch meta such as is_banned and is_member
 	);
 
@@ -1844,5 +1853,5 @@
 }
 
-function groups_get_user_groups( $user_id = false, $pag_num = false, $pag_page = false ) {
+function groups_get_user_groups( $user_id = 0, $pag_num = 0, $pag_page = 0 ) {
 	global $bp;
 
@@ -1853,5 +1862,5 @@
 }
 
-function groups_total_groups_for_user( $user_id = false ) {
+function groups_total_groups_for_user( $user_id = 0 ) {
 	global $bp;
 
@@ -1869,5 +1878,5 @@
 /*** Group Avatars *************************************************************/
 
-function groups_avatar_upload_dir( $group_id = false ) {
+function groups_avatar_upload_dir( $group_id = 0 ) {
 	global $bp;
 
@@ -1875,5 +1884,5 @@
 		$group_id = $bp->groups->current_group->id;
 
-	$path = BP_AVATAR_UPLOAD_PATH . '/group-avatars/' . $group_id;
+	$path    = BP_AVATAR_UPLOAD_PATH . '/group-avatars/' . $group_id;
 	$newbdir = $path;
 
@@ -1881,6 +1890,6 @@
 		@wp_mkdir_p( $path );
 
-	$newurl = BP_AVATAR_URL . '/group-avatars/' . $group_id;
-	$newburl = $newurl;
+	$newurl    = BP_AVATAR_URL . '/group-avatars/' . $group_id;
+	$newburl   = $newurl;
 	$newsubdir = '/group-avatars/' . $group_id;
 
@@ -1924,6 +1933,6 @@
 
 	$defaults = array(
-		'content' => false,
-		'user_id' => $bp->loggedin_user->id,
+		'content'  => false,
+		'user_id'  => $bp->loggedin_user->id,
 		'group_id' => $bp->groups->current_group->id
 	);
@@ -1932,26 +1941,27 @@
 	extract( $r, EXTR_SKIP );
 
-	if ( empty($content) || !strlen( trim( $content ) ) || empty($user_id) || empty($group_id) )
+	if ( empty( $content ) || !strlen( trim( $content ) ) || empty( $user_id ) || empty( $group_id ) )
 		return false;
 
 	$bp->groups->current_group = new BP_Groups_Group( $group_id );
 
-	/* Be sure the user is a member of the group before posting. */
+	// Be sure the user is a member of the group before posting.
 	if ( !is_super_admin() && !groups_is_user_member( $user_id, $group_id ) )
 		return false;
 
-	/* Record this in activity streams */
-	$activity_action = sprintf( __( '%1$s posted an update in the group %2$s:', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . esc_attr( $bp->groups->current_group->name ) . '</a>' );
+	// Record this in activity streams
+	$activity_action  = sprintf( __( '%1$s posted an update in the group %2$s:', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . esc_attr( $bp->groups->current_group->name ) . '</a>' );
 	$activity_content = $content;
 
 	$activity_id = groups_record_activity( array(
 		'user_id' => $user_id,
-		'action' => apply_filters( 'groups_activity_new_update_action', $activity_action ),
+		'action'  => apply_filters( 'groups_activity_new_update_action',  $activity_action  ),
 		'content' => apply_filters( 'groups_activity_new_update_content', $activity_content ),
-		'type' => 'activity_update',
+		'type'    => 'activity_update',
 		'item_id' => $group_id
 	) );
 
- 	/* Require the notifications code so email notifications can be set on the 'bp_activity_posted_update' action. */
+ 	// Require the notifications code so email notifications can be set on
+	// the 'bp_activity_posted_update' action.
 	require_once( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
 
@@ -1964,5 +1974,5 @@
 /*** Group Forums **************************************************************/
 
-function groups_new_group_forum( $group_id = false, $group_name = false, $group_desc = false ) {
+function groups_new_group_forum( $group_id = 0, $group_name = '', $group_desc = '' ) {
 	global $bp;
 
@@ -2008,5 +2018,5 @@
 
 	$post_text = apply_filters( 'group_forum_post_text_before_save', $post_text );
-	$topic_id = apply_filters( 'group_forum_post_topic_id_before_save', $topic_id );
+	$topic_id  = apply_filters( 'group_forum_post_topic_id_before_save', $topic_id );
 
 	if ( $post_id = bp_forums_insert_post( array( 'post_text' => $post_text, 'topic_id' => $topic_id ) ) ) {
@@ -2020,11 +2030,11 @@
 			$primary_link .= "?topic_page=" . $page;
 
-		/* Record this in activity streams */
+		// Record this in activity streams
 		groups_record_activity( array(
-			'action' => apply_filters( 'groups_activity_new_forum_post_action', $activity_action, $post_id, $post_text, &$topic ),
-			'content' => apply_filters( 'groups_activity_new_forum_post_content', $activity_content, $post_id, $post_text, &$topic ),
-			'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', "{$primary_link}#post-{$post_id}" ),
-			'type' => 'new_forum_post',
-			'item_id' => $bp->groups->current_group->id,
+			'action'            => apply_filters( 'groups_activity_new_forum_post_action', $activity_action, $post_id, $post_text, &$topic ),
+			'content'           => apply_filters( 'groups_activity_new_forum_post_content', $activity_content, $post_id, $post_text, &$topic ),
+			'primary_link'      => apply_filters( 'groups_activity_new_forum_post_primary_link', "{$primary_link}#post-{$post_id}" ),
+			'type'              => 'new_forum_post',
+			'item_id'           => $bp->groups->current_group->id,
 			'secondary_item_id' => $post_id
 		) );
@@ -2045,7 +2055,7 @@
 
 	$topic_title = apply_filters( 'group_forum_topic_title_before_save', $topic_title );
-	$topic_text = apply_filters( 'group_forum_topic_text_before_save', $topic_text );
-	$topic_tags = apply_filters( 'group_forum_topic_tags_before_save', $topic_tags );
-	$forum_id = apply_filters( 'group_forum_topic_forum_id_before_save', $forum_id );
+	$topic_text  = apply_filters( 'group_forum_topic_text_before_save', $topic_text );
+	$topic_tags  = apply_filters( 'group_forum_topic_tags_before_save', $topic_tags );
+	$forum_id    = apply_filters( 'group_forum_topic_forum_id_before_save', $forum_id );
 
 	if ( $topic_id = bp_forums_new_topic( array( 'topic_title' => $topic_title, 'topic_text' => $topic_text, 'topic_tags' => $topic_tags, 'forum_id' => $forum_id ) ) ) {
@@ -2055,11 +2065,11 @@
 		$activity_content = bp_create_excerpt( $topic_text );
 
-		/* Record this in activity streams */
+		// Record this in activity streams
 		groups_record_activity( array(
-			'action' => apply_filters( 'groups_activity_new_forum_topic_action', $activity_action, $topic_text, &$topic ),
-			'content' => apply_filters( 'groups_activity_new_forum_topic_content', $activity_content, $topic_text, &$topic ),
-			'primary_link' => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/' ),
-			'type' => 'new_forum_topic',
-			'item_id' => $bp->groups->current_group->id,
+			'action'            => apply_filters( 'groups_activity_new_forum_topic_action', $activity_action, $topic_text, &$topic ),
+			'content'           => apply_filters( 'groups_activity_new_forum_topic_content', $activity_content, $topic_text, &$topic ),
+			'primary_link'      => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/' ),
+			'type'              => 'new_forum_topic',
+			'item_id'           => $bp->groups->current_group->id,
 			'secondary_item_id' => $topic->topic_id
 		) );
@@ -2077,8 +2087,8 @@
 
 	$topic_title = apply_filters( 'group_forum_topic_title_before_save', $topic_title );
-	$topic_text = apply_filters( 'group_forum_topic_text_before_save', $topic_text );
+	$topic_text  = apply_filters( 'group_forum_topic_text_before_save',  $topic_text  );
 
 	if ( $topic = bp_forums_update_topic( array( 'topic_title' => $topic_title, 'topic_text' => $topic_text, 'topic_id' => $topic_id ) ) ) {
-		/* Update the activity stream item */
+		// Update the activity stream item
 		if ( function_exists( 'bp_activity_delete_by_item_id' ) )
 			bp_activity_delete_by_item_id( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $topic_id, 'component' => $bp->groups->id, 'type' => 'new_forum_topic' ) );
@@ -2087,14 +2097,14 @@
 		$activity_content = bp_create_excerpt( $topic_text );
 
-		/* Record this in activity streams */
+		// Record this in activity streams
 		groups_record_activity( array(
-			'action' => apply_filters( 'groups_activity_new_forum_topic_action', $activity_action, $topic_text, &$topic ),
-			'content' => apply_filters( 'groups_activity_new_forum_topic_content', $activity_content, $topic_text, &$topic ),
-			'primary_link' => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/' ),
-			'type' => 'new_forum_topic',
-			'item_id' => (int)$bp->groups->current_group->id,
-			'user_id' => (int)$topic->topic_poster,
+			'action'            => apply_filters( 'groups_activity_new_forum_topic_action', $activity_action, $topic_text, &$topic ),
+			'content'           => apply_filters( 'groups_activity_new_forum_topic_content', $activity_content, $topic_text, &$topic ),
+			'primary_link'      => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/' ),
+			'type'              => 'new_forum_topic',
+			'item_id'           => (int)$bp->groups->current_group->id,
+			'user_id'           => (int)$topic->topic_poster,
 			'secondary_item_id' => $topic->topic_id,
-			'recorded_time' => $topic->topic_time
+			'recorded_time '    => $topic->topic_time
 		) );
 
@@ -2111,7 +2121,6 @@
 
 	$post_text = apply_filters( 'group_forum_post_text_before_save', $post_text );
-	$topic_id = apply_filters( 'group_forum_post_topic_id_before_save', $topic_id );
-
-	$post = bp_forums_get_post( $post_id );
+	$topic_id  = apply_filters( 'group_forum_post_topic_id_before_save', $topic_id );
+	$post      = bp_forums_get_post( $post_id );
 
 	if ( $post_id = bp_forums_insert_post( array( 'post_id' => $post_id, 'post_text' => $post_text, 'post_time' => $post->post_time, 'topic_id' => $topic_id, 'poster_id' => $post->poster_id ) ) ) {
@@ -2125,19 +2134,19 @@
 			$primary_link .= "?topic_page=" . $page;
 
-		/* Fetch an existing entry and update if one exists. */
+		// Fetch an existing entry and update if one exists.
 		if ( function_exists( 'bp_activity_get_activity_id' ) )
 			$id = bp_activity_get_activity_id( array( 'user_id' => $post->poster_id, 'component' => $bp->groups->id, 'type' => 'new_forum_post', 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $post_id ) );
 
-		/* Update the entry in activity streams */
+		// Update the entry in activity streams
 		groups_record_activity( array(
-			'id' => $id,
-			'action' => apply_filters( 'groups_activity_new_forum_post_action', $activity_action, $post_text, &$topic, &$forum_post ),
-			'content' => apply_filters( 'groups_activity_new_forum_post_content', $activity_content, $post_text, &$topic, &$forum_post ),
-			'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', $primary_link . "#post-" . $post_id ),
-			'type' => 'new_forum_post',
-			'item_id' => (int)$bp->groups->current_group->id,
-			'user_id' => (int)$post->poster_id,
+			'id'                => $id,
+			'action'            => apply_filters( 'groups_activity_new_forum_post_action', $activity_action, $post_text, &$topic, &$forum_post ),
+			'content'           => apply_filters( 'groups_activity_new_forum_post_content', $activity_content, $post_text, &$topic, &$forum_post ),
+			'primary_link'      => apply_filters( 'groups_activity_new_forum_post_primary_link', $primary_link . "#post-" . $post_id ),
+			'type'              => 'new_forum_post',
+			'item_id'           => (int)$bp->groups->current_group->id,
+			'user_id'           => (int)$post->poster_id,
 			'secondary_item_id' => $post_id,
-			'recorded_time' => $post->post_time
+			'recorded_time'     => $post->post_time
 		) );
 
@@ -2156,8 +2165,7 @@
 		do_action( 'groups_before_delete_group_forum_topic', $topic_id );
 
-		/* Delete the activity stream item */
-		if ( function_exists( 'bp_activity_delete' ) ) {
+		// Delete the activity stream item
+		if ( function_exists( 'bp_activity_delete' ) )
 			bp_activity_delete( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $topic_id, 'component' => $bp->groups->id, 'type' => 'new_forum_topic' ) );
-		}
 
 		do_action( 'groups_delete_group_forum_topic', $topic_id );
@@ -2175,8 +2183,7 @@
 		do_action( 'groups_before_delete_group_forum_post', $post_id, $topic_id );
 
-		/* Delete the activity stream item */
-		if ( function_exists( 'bp_activity_delete' ) ) {
+		// Delete the activity stream item
+		if ( function_exists( 'bp_activity_delete' ) )
 			bp_activity_delete( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $post_id, 'component' => $bp->groups->id, 'type' => 'new_forum_post' ) );
-		}
 
 		do_action( 'groups_delete_group_forum_post', $post_id, $topic_id );
@@ -2208,9 +2215,9 @@
 
 	$defaults = array(
-		'user_id' => false,
-		'group_id' => false,
-		'inviter_id' => $bp->loggedin_user->id,
+		'user_id'       => false,
+		'group_id'      => false,
+		'inviter_id'    => $bp->loggedin_user->id,
 		'date_modified' => bp_core_current_time(),
-		'is_confirmed' => 0
+		'is_confirmed'  => 0
 	);
 
@@ -2222,10 +2229,10 @@
 
 	if ( !groups_is_user_member( $user_id, $group_id ) && !groups_check_user_has_invite( $user_id, $group_id ) ) {
-		$invite = new BP_Groups_Member;
-		$invite->group_id = $group_id;
-		$invite->user_id = $user_id;
+		$invite                = new BP_Groups_Member;
+		$invite->group_id      = $group_id;
+		$invite->user_id       = $user_id;
 		$invite->date_modified = $date_modified;
-		$invite->inviter_id = $inviter_id;
-		$invite->is_confirmed = $is_confirmed;
+		$invite->inviter_id    = $inviter_id;
+		$invite->is_confirmed  = $is_confirmed;
 
 		if ( !$invite->save() )
@@ -2261,9 +2268,9 @@
 		return false;
 
-	/* Remove request to join */
+	// Remove request to join
 	if ( $member->check_for_membership_request( $user_id, $group_id ) )
 		$member->delete_request( $user_id, $group_id );
 
-	/* Modify group meta */
+	// Modify group meta
 	groups_update_groupmeta( $group_id, 'total_member_count', (int) groups_get_groupmeta( $group_id, 'total_member_count') + 1 );
 	groups_update_groupmeta( $group_id, 'last_activity', bp_core_current_time() );
@@ -2403,21 +2410,21 @@
 	global $bp;
 
-	/* Prevent duplicate requests */
+	// Prevent duplicate requests
 	if ( groups_check_for_membership_request( $requesting_user_id, $group_id ) )
 		return false;
 
-	/* Check if the user is already a member or is banned */
+	// Check if the user is already a member or is banned
 	if ( groups_is_user_member( $requesting_user_id, $group_id ) || groups_is_user_banned( $requesting_user_id, $group_id ) )
 		return false;
 
-	$requesting_user = new BP_Groups_Member;
-	$requesting_user->group_id = $group_id;
-	$requesting_user->user_id = $requesting_user_id;
-	$requesting_user->inviter_id = 0;
-	$requesting_user->is_admin = 0;
-	$requesting_user->user_title = '';
+	$requesting_user                = new BP_Groups_Member;
+	$requesting_user->group_id      = $group_id;
+	$requesting_user->user_id       = $requesting_user_id;
+	$requesting_user->inviter_id    = 0;
+	$requesting_user->is_admin      = 0;
+	$requesting_user->user_title    = '';
 	$requesting_user->date_modified = bp_core_current_time();
-	$requesting_user->is_confirmed = 0;
-	$requesting_user->comments = $_POST['group-request-membership-comments'];
+	$requesting_user->is_confirmed  = 0;
+	$requesting_user->comments      = $_POST['group-request-membership-comments'];
 
 	if ( $requesting_user->save() ) {
@@ -2426,8 +2433,7 @@
 		require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
 
-		for ( $i = 0; $i < count( $admins ); $i++ ) {
-			// Saved okay, now send the email notification
+		// Saved okay, now send the email notification
+		for ( $i = 0; $i < count( $admins ); $i++ )
 			groups_notification_new_membership_request( $requesting_user_id, $admins[$i]->user_id, $group_id, $requesting_user->id );
-		}
 
 		do_action( 'groups_membership_requested', $requesting_user_id, $admins, $group_id, $requesting_user->id );
@@ -2452,22 +2458,22 @@
 		return false;
 
-	/* Check if the user has an outstanding invite, if so delete it. */
+	// Check if the user has an outstanding invite, if so delete it.
 	if ( groups_check_user_has_invite( $membership->user_id, $membership->group_id ) )
 		groups_delete_invite( $membership->user_id, $membership->group_id );
 
-	/* Modify group member count */
+	// Modify group member count
 	groups_update_groupmeta( $membership->group_id, 'total_member_count', (int) groups_get_groupmeta( $membership->group_id, 'total_member_count') + 1 );
 
-	/* Record this in activity streams */
+	// Record this in activity streams
 	$group = new BP_Groups_Group( $membership->group_id );
 
 	groups_record_activity( array(
-		'action'	=> apply_filters( 'groups_activity_membership_accepted_action', sprintf( __( '%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink( $membership->user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . esc_attr( $group->name ) . '</a>' ), $membership->user_id, &$group ),
-		'type'		=> 'joined_group',
-		'item_id'	=> $membership->group_id,
-		'user_id'	=> $membership->user_id
+		'action'  => apply_filters( 'groups_activity_membership_accepted_action', sprintf( __( '%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink( $membership->user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . esc_attr( $group->name ) . '</a>' ), $membership->user_id, &$group ),
+		'type'    => 'joined_group',
+		'item_id' => $membership->group_id,
+		'user_id' => $membership->user_id
 	) );
 
-	/* Send a notification to the user. */
+	// Send a notification to the user.
 	require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
 	groups_notification_membership_request_completed( $membership->user_id, $membership->group_id, true );
@@ -2513,7 +2519,6 @@
 		return false;
 
-	foreach ( (array) $user_ids as $user_id ) {
+	foreach ( (array) $user_ids as $user_id )
 		groups_accept_membership_request( false, $user_id, $group_id );
-	}
 
 	do_action( 'groups_accept_all_pending_membership_requests', $group_id );
@@ -2530,20 +2535,19 @@
 		return false;
 
-	$meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
-
-	if ( is_array($meta_value) || is_object($meta_value) )
+	$meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
+
+	if ( is_array( $meta_value ) || is_object( $meta_value ) )
 		$meta_value = serialize($meta_value);
 
 	$meta_value = trim( $meta_value );
 
-	if ( !$meta_key ) {
+	if ( !$meta_key )
 		$wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d", $group_id ) );
-	} else if ( $meta_value ) {
+	else if ( $meta_value )
 		$wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d AND meta_key = %s AND meta_value = %s", $group_id, $meta_key, $meta_value ) );
-	} else {
+	else
 		$wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d AND meta_key = %s", $group_id, $meta_key ) );
-	}
-
-	/* Delete the cached object */
+
+	// Delete the cached object
 	wp_cache_delete( 'bp_groups_groupmeta_' . $group_id . '_' . $meta_key, 'bp' );
 
@@ -2560,5 +2564,5 @@
 
 	if ( !empty($meta_key) ) {
-		$meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
+		$meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
 
 		if ( !$metas = wp_cache_get( 'bp_groups_groupmeta_' . $group_id . '_' . $meta_key, 'bp' ) ) {
@@ -2570,6 +2574,6 @@
 	}
 
-	if ( empty($metas) ) {
-		if ( empty($meta_key) )
+	if ( empty( $metas ) ) {
+		if ( empty( $meta_key ) )
 			return array();
 		else
@@ -2577,7 +2581,7 @@
 	}
 
-	$metas = array_map('maybe_unserialize', (array)$metas);
-
-	if ( 1 == count($metas) )
+	$metas = array_map( 'maybe_unserialize', (array)$metas );
+
+	if ( 1 == count( $metas ) )
 		return $metas[0];
 	else
@@ -2593,24 +2597,22 @@
 	$meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
 
-	if ( is_string($meta_value) )
-		$meta_value = stripslashes($wpdb->escape($meta_value));
-
-	$meta_value = maybe_serialize($meta_value);
-
-	if (empty($meta_value)) {
+	if ( is_string( $meta_value ) )
+		$meta_value = stripslashes( $wpdb->escape( $meta_value ) );
+
+	$meta_value = maybe_serialize( $meta_value );
+
+	if ( empty( $meta_value ) )
 		return groups_delete_groupmeta( $group_id, $meta_key );
-	}
 
 	$cur = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d AND meta_key = %s", $group_id, $meta_key ) );
 
-	if ( !$cur ) {
+	if ( !$cur )
 		$wpdb->query( $wpdb->prepare( "INSERT INTO " . $bp->groups->table_name_groupmeta . " ( group_id, meta_key, meta_value ) VALUES ( %d, %s, %s )", $group_id, $meta_key, $meta_value ) );
-	} else if ( $cur->meta_value != $meta_value ) {
+	else if ( $cur->meta_value != $meta_value )
 		$wpdb->query( $wpdb->prepare( "UPDATE " . $bp->groups->table_name_groupmeta . " SET meta_value = %s WHERE group_id = %d AND meta_key = %s", $meta_value, $group_id, $meta_key ) );
-	} else {
-		return false;
-	}
-
-	/* Update the cached object and recache */
+	else
+		return false;
+
+	// Update the cached object and recache
 	wp_cache_set( 'bp_groups_groupmeta_' . $group_id . '_' . $meta_key, $meta_value, 'bp' );
 
@@ -2621,10 +2623,10 @@
 
 function groups_remove_data_for_user( $user_id ) {
-	BP_Groups_Member::delete_all_for_user($user_id);
+	BP_Groups_Member::delete_all_for_user( $user_id );
 
 	do_action( 'groups_remove_data_for_user', $user_id );
 }
-add_action( 'wpmu_delete_user', 'groups_remove_data_for_user' );
-add_action( 'delete_user', 'groups_remove_data_for_user' );
+add_action( 'wpmu_delete_user',  'groups_remove_data_for_user' );
+add_action( 'delete_user',       'groups_remove_data_for_user' );
 add_action( 'bp_make_spam_user', 'groups_remove_data_for_user' );
 
@@ -2640,8 +2642,8 @@
 	wp_cache_delete( 'bp_total_group_count', 'bp' );
 }
-add_action( 'groups_group_deleted', 'groups_clear_group_object_cache' );
-add_action( 'groups_settings_updated', 'groups_clear_group_object_cache' );
-add_action( 'groups_details_updated', 'groups_clear_group_object_cache' );
-add_action( 'groups_group_avatar_updated', 'groups_clear_group_object_cache' );
+add_action( 'groups_group_deleted',              'groups_clear_group_object_cache' );
+add_action( 'groups_settings_updated',           'groups_clear_group_object_cache' );
+add_action( 'groups_details_updated',            'groups_clear_group_object_cache' );
+add_action( 'groups_group_avatar_updated',       'groups_clear_group_object_cache' );
 add_action( 'groups_create_group_step_complete', 'groups_clear_group_object_cache' );
 
@@ -2649,28 +2651,28 @@
 	wp_cache_delete( 'bp_total_groups_for_user_' . $user_id );
 }
-add_action( 'groups_join_group', 'groups_clear_group_user_object_cache', 10, 2 );
-add_action( 'groups_leave_group', 'groups_clear_group_user_object_cache', 10, 2 );
-add_action( 'groups_ban_member', 'groups_clear_group_user_object_cache', 10, 2 );
+add_action( 'groups_join_group',   'groups_clear_group_user_object_cache', 10, 2 );
+add_action( 'groups_leave_group',  'groups_clear_group_user_object_cache', 10, 2 );
+add_action( 'groups_ban_member',   'groups_clear_group_user_object_cache', 10, 2 );
 add_action( 'groups_unban_member', 'groups_clear_group_user_object_cache', 10, 2 );
 
 /* List actions to clear super cached pages on, if super cache is installed */
-add_action( 'groups_join_group', 'bp_core_clear_cache' );
-add_action( 'groups_leave_group', 'bp_core_clear_cache' );
-add_action( 'groups_accept_invite', 'bp_core_clear_cache' );
-add_action( 'groups_reject_invite', 'bp_core_clear_cache' );
-add_action( 'groups_invite_user', 'bp_core_clear_cache' );
-add_action( 'groups_uninvite_user', 'bp_core_clear_cache' );
-add_action( 'groups_details_updated', 'bp_core_clear_cache' );
-add_action( 'groups_settings_updated', 'bp_core_clear_cache' );
-add_action( 'groups_unban_member', 'bp_core_clear_cache' );
-add_action( 'groups_ban_member', 'bp_core_clear_cache' );
-add_action( 'groups_demote_member', 'bp_core_clear_cache' );
-add_action( 'groups_premote_member', 'bp_core_clear_cache' );
-add_action( 'groups_membership_rejected', 'bp_core_clear_cache' );
-add_action( 'groups_membership_accepted', 'bp_core_clear_cache' );
-add_action( 'groups_membership_requested', 'bp_core_clear_cache' );
+add_action( 'groups_join_group',                 'bp_core_clear_cache' );
+add_action( 'groups_leave_group',                'bp_core_clear_cache' );
+add_action( 'groups_accept_invite',              'bp_core_clear_cache' );
+add_action( 'groups_reject_invite',              'bp_core_clear_cache' );
+add_action( 'groups_invite_user',                'bp_core_clear_cache' );
+add_action( 'groups_uninvite_user',              'bp_core_clear_cache' );
+add_action( 'groups_details_updated',            'bp_core_clear_cache' );
+add_action( 'groups_settings_updated',           'bp_core_clear_cache' );
+add_action( 'groups_unban_member',               'bp_core_clear_cache' );
+add_action( 'groups_ban_member',                 'bp_core_clear_cache' );
+add_action( 'groups_demote_member',              'bp_core_clear_cache' );
+add_action( 'groups_premote_member',             'bp_core_clear_cache' );
+add_action( 'groups_membership_rejected',        'bp_core_clear_cache' );
+add_action( 'groups_membership_accepted',        'bp_core_clear_cache' );
+add_action( 'groups_membership_requested',       'bp_core_clear_cache' );
 add_action( 'groups_create_group_step_complete', 'bp_core_clear_cache' );
-add_action( 'groups_created_group', 'bp_core_clear_cache' );
-add_action( 'groups_group_avatar_updated', 'bp_core_clear_cache' );
+add_action( 'groups_created_group',              'bp_core_clear_cache' );
+add_action( 'groups_group_avatar_updated',       'bp_core_clear_cache' );
 
 ?>
Index: /trunk/bp-groups/bp-groups-templatetags.php
===================================================================
--- /trunk/bp-groups/bp-groups-templatetags.php	(revision 3727)
+++ /trunk/bp-groups/bp-groups-templatetags.php	(revision 3728)
@@ -351,5 +351,5 @@
 			$group =& $groups_template->group;
 
-		return apply_filters( 'bp_get_group_permalink', $bp->root_domain . '/' . $bp->groups->slug . '/' . $group->slug . '/' );
+		return apply_filters( 'bp_get_group_permalink', $bp->root_domain . '/' . $bp->groups->root_slug . '/' . $group->slug . '/' );
 	}
 
@@ -363,5 +363,5 @@
 			$group =& $groups_template->group;
 
-		return apply_filters( 'bp_get_group_admin_permalink', $bp->root_domain . '/' . $bp->groups->slug . '/' . $group->slug . '/admin' );
+		return apply_filters( 'bp_get_group_admin_permalink', $bp->root_domain . '/' . $bp->groups->root_slug . '/' . $group->slug . '/admin' );
 	}
 
@@ -548,5 +548,5 @@
 	global $bp;
 
-	if ( !$bp->is_single_item || $bp->current_component != $bp->groups->slug || $bp->current_action != $bp->activity->slug )
+	if ( !$bp->is_single_item || !bp_is_current_component( $bp->groups->slug ) || $bp->current_action != $bp->activity->slug )
 		return false;
 
@@ -930,5 +930,5 @@
 ?>
 	<?php if ( $bp->is_item_admin || $bp->is_item_mod ) { ?>
-		<li<?php if ( 'edit-details' == $current_tab || empty( $current_tab ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/edit-details"><?php _e('Edit Details', 'buddypress') ?></a></li>
+		<li<?php if ( 'edit-details' == $current_tab || empty( $current_tab ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->root_slug ?>/<?php echo $group->slug ?>/admin/edit-details"><?php _e('Edit Details', 'buddypress') ?></a></li>
 	<?php } ?>
 
@@ -937,15 +937,15 @@
 			return false;
 	?>
-	<li<?php if ( 'group-settings' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/group-settings"><?php _e('Group Settings', 'buddypress') ?></a></li>
-	<li<?php if ( 'group-avatar' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/group-avatar"><?php _e('Group Avatar', 'buddypress') ?></a></li>
-	<li<?php if ( 'manage-members' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/manage-members"><?php _e('Manage Members', 'buddypress') ?></a></li>
+	<li<?php if ( 'group-settings' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->root_slug ?>/<?php echo $group->slug ?>/admin/group-settings"><?php _e('Group Settings', 'buddypress') ?></a></li>
+	<li<?php if ( 'group-avatar' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->root_slug ?>/<?php echo $group->slug ?>/admin/group-avatar"><?php _e('Group Avatar', 'buddypress') ?></a></li>
+	<li<?php if ( 'manage-members' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->root_slug ?>/<?php echo $group->slug ?>/admin/manage-members"><?php _e('Manage Members', 'buddypress') ?></a></li>
 
 	<?php if ( $groups_template->group->status == 'private' ) : ?>
-		<li<?php if ( 'membership-requests' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/membership-requests"><?php _e('Membership Requests', 'buddypress') ?></a></li>
+		<li<?php if ( 'membership-requests' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->root_slug ?>/<?php echo $group->slug ?>/admin/membership-requests"><?php _e('Membership Requests', 'buddypress') ?></a></li>
 	<?php endif; ?>
 
 	<?php do_action( 'groups_admin_tabs', $current_tab, $group->slug ) ?>
 
-	<li<?php if ( 'delete-group' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/delete-group"><?php _e('Delete Group', 'buddypress') ?></a></li>
+	<li<?php if ( 'delete-group' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->root_slug ?>/<?php echo $group->slug ?>/admin/delete-group"><?php _e('Delete Group', 'buddypress') ?></a></li>
 <?php
 }
@@ -1620,5 +1620,5 @@
 		$is_enabled = bp_are_previous_group_creation_steps_complete( $slug ); ?>
 
-		<li<?php if ( $bp->groups->current_create_step == $slug ) : ?> class="current"<?php endif; ?>><?php if ( $is_enabled ) : ?><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/create/step/<?php echo $slug ?>/"><?php else: ?><span><?php endif; ?><?php echo $counter ?>. <?php echo $step['name'] ?><?php if ( $is_enabled ) : ?></a><?php else: ?></span><?php endif ?></li><?php
+		<li<?php if ( $bp->groups->current_create_step == $slug ) : ?> class="current"<?php endif; ?>><?php if ( $is_enabled ) : ?><a href="<?php echo $bp->root_domain . '/' . $bp->groups->root_slug ?>/create/step/<?php echo $slug ?>/"><?php else: ?><span><?php endif; ?><?php echo $counter ?>. <?php echo $step['name'] ?><?php if ( $is_enabled ) : ?></a><?php else: ?></span><?php endif ?></li><?php
 		$counter++;
 	}
@@ -1644,5 +1644,5 @@
 			$bp->action_variables[1] = array_shift( array_keys( $bp->groups->group_creation_steps ) );
 
-		return apply_filters( 'bp_get_group_creation_form_action', $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . $bp->action_variables[1] );
+		return apply_filters( 'bp_get_group_creation_form_action', $bp->root_domain . '/' . $bp->groups->root_slug . '/create/step/' . $bp->action_variables[1] );
 	}
 
@@ -1651,5 +1651,5 @@
 
 	/* Make sure we are in the groups component */
-	if ( $bp->current_component != BP_GROUPS_SLUG || 'create' != $bp->current_action )
+	if ( !bp_is_current_component( $bp->groups->slug ) || 'create' != $bp->current_action )
 		return false;
 
@@ -1930,5 +1930,5 @@
 	global $bp;
 
-	if ( $bp->current_component != BP_GROUPS_SLUG || 'admin' != $bp->current_action )
+	if ( !bp_is_current_component( $bp->groups->slug ) || 'admin' != $bp->current_action )
 		return false;
 
@@ -1947,7 +1947,11 @@
 
 	if ( $bp->groups->current_group->avatar_full ) { ?>
+
 		<img src="<?php echo esc_attr( $bp->groups->current_group->avatar_full ) ?>" alt="<?php _e( 'Group Avatar', 'buddypress' ) ?>" class="avatar" />
+
 	<?php } else { ?>
+
 		<img src="<?php echo $bp->groups->image_base . '/none.gif' ?>" alt="<?php _e( 'No Group Avatar', 'buddypress' ) ?>" class="avatar" />
+
 	<?php }
 }
@@ -2041,5 +2045,5 @@
 			'next_text' => '&rarr;',
 			'mid_size' => 1
-		));
+		) );
 	}
 
@@ -2060,7 +2064,7 @@
 	function rewind_requests() {
 		$this->current_request = -1;
-		if ( $this->request_count > 0 ) {
+
+		if ( $this->request_count > 0 )
 			$this->request = $this->requests[0];
-		}
 	}
 
@@ -2095,5 +2099,5 @@
 		'group_id' => $groups_template->group->id,
 		'per_page' => 10,
-		'max' => false
+		'max'      => false
 	);
 
@@ -2202,7 +2206,6 @@
 	function rewind_invites() {
 		$this->current_invite = -1;
-		if ( $this->invite_count > 0 ) {
+		if ( $this->invite_count > 0 )
 			$this->invite = $this->invites[0];
-		}
 	}
 
@@ -2247,7 +2250,8 @@
 
 	if ( !$group_id ) {
-		/* Backwards compatibility */
+		// Backwards compatibility
 		if ( !empty( $bp->groups->current_group ) )
 			$group_id = $bp->groups->current_group->id;
+
 		if ( !empty( $bp->groups->new_group_id ) )
 			$group_id = $bp->groups->new_group_id;
Index: /trunk/bp-loader.php
===================================================================
--- /trunk/bp-loader.php	(revision 3727)
+++ /trunk/bp-loader.php	(revision 3728)
@@ -38,29 +38,29 @@
 	do_action( 'bp_core_loaded' );
 
-	/* Activity Streams */
+	// Activity Streams
 	if ( !isset( $bp_deactivated['bp-activity.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-activity.php') )
 		include( BP_PLUGIN_DIR . '/bp-activity.php' );
 
-	/* Blog Tracking */
+	// Blog Tracking
 	if ( !isset( $bp_deactivated['bp-blogs.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-blogs.php') )
 		include( BP_PLUGIN_DIR . '/bp-blogs.php' );
 
-	/* bbPress Forum Integration */
+	// bbPress Forum Integration
 	if ( !isset( $bp_deactivated['bp-forums.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-forums.php') )
 		include( BP_PLUGIN_DIR . '/bp-forums.php' );
 
-	/* Friend Connections */
+	// Friend Connections
 	if ( !isset( $bp_deactivated['bp-friends.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-friends.php') )
 		include( BP_PLUGIN_DIR . '/bp-friends.php' );
 
-	/* Groups Support */
+	// Groups Support
 	if ( !isset( $bp_deactivated['bp-groups.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-groups.php') )
 		include( BP_PLUGIN_DIR . '/bp-groups.php' );
 
-	/* Private Messaging */
+	// Private Messaging
 	if ( !isset( $bp_deactivated['bp-messages.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-messages.php') )
 		include( BP_PLUGIN_DIR . '/bp-messages.php' );
 
-	/* Extended Profiles */
+	// Extended Profiles
 	if ( !isset( $bp_deactivated['bp-xprofile.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-xprofile.php') )
 		include( BP_PLUGIN_DIR . '/bp-xprofile.php' );
@@ -70,11 +70,9 @@
 
 /**
-* bp_loaded()
-*
-* Allow dependent plugins and core actions to attach themselves in a safe way.
-*
-* See bp-core.php for the following core actions:
-*      - bp_init|bp_setup_globals|bp_setup_root_components|bp_setup_nav|bp_register_widgets
-*/
+ * Allow dependent plugins and core actions to attach themselves in a safe way.
+ *
+ * See bp-core.php for the following core actions:
+ *      - bp_init|bp_setup_globals|bp_setup_root_components|bp_setup_nav|bp_register_widgets
+ */
 function bp_loaded() {
 	do_action( 'bp_loaded' );
@@ -82,6 +80,4 @@
 
 /**
- * bp_core_get_site_options()
- *
  * BuddyPress uses site options to store configuration settings. Many of these settings are needed
  * at run time. Instead of fetching them all and adding many initial queries to each page load, let's fetch
@@ -126,8 +122,7 @@
 		$site_meta = $wpdb->get_results( "SELECT option_name AS name, option_value AS value FROM {$wpdb->options} WHERE option_name IN ({$meta_keys})" );
 
-	$root_blog_meta_keys = "'" . implode( "','", (array)$root_blog_options ) ."'";
-
+	$root_blog_meta_keys  = "'" . implode( "','", (array)$root_blog_options ) ."'";
 	$root_blog_meta_table = $wpdb->get_blog_prefix( BP_ROOT_BLOG ) . 'options';
-	$root_blog_meta = $wpdb->get_results( $wpdb->prepare( "SELECT option_name AS name, option_value AS value FROM {$root_blog_meta_table} WHERE option_name IN ({$root_blog_meta_keys})" ) );
+	$root_blog_meta       = $wpdb->get_results( $wpdb->prepare( "SELECT option_name AS name, option_value AS value FROM {$root_blog_meta_table} WHERE option_name IN ({$root_blog_meta_keys})" ) );
 
 	$site_options = array();
@@ -141,10 +136,11 @@
 }
 
-/* Activation Function */
+// Activation Function
 function bp_loader_activate() {
-	/* Force refresh theme roots. */
+	// Force refresh theme roots.
 	delete_site_transient( 'theme_roots' );
 
-	/* Switch the user to the new bp-default if they are using the old bp-default on activation. */
+	// Switch the user to the new bp-default if they are using the old
+	// bp-default on activation.
 	if ( 'bp-sn-parent' == get_blog_option( BP_ROOT_BLOG, 'template' ) && 'bp-default' == get_blog_option( BP_ROOT_BLOG, 'stylesheet' ) )
 		switch_theme( 'bp-default', 'bp-default' );
@@ -154,5 +150,5 @@
 register_activation_hook( 'buddypress/bp-loader.php', 'bp_loader_activate' );
 
-/* Deactivation Function */
+// Deactivation Function
 function bp_loader_deactivate() {
 	do_action( 'bp_loader_deactivate' );
Index: /trunk/bp-messages.php
===================================================================
--- /trunk/bp-messages.php	(revision 3727)
+++ /trunk/bp-messages.php	(revision 3728)
@@ -1,7 +1,9 @@
 <?php
-require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-classes.php' );
-require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-cssjs.php' );
+
+// Required Files
+require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-classes.php'      );
+require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-cssjs.php'        );
 require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-templatetags.php' );
-require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-filters.php' );
+require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-filters.php'      );
 
 function messages_setup_globals() {
@@ -14,8 +16,13 @@
 	$bp->messages->id = 'messages';
 
+	// Slug
 	$bp->messages->slug = BP_MESSAGES_SLUG;
+
+	// Tables
 	$bp->messages->table_name_notices 		= $bp->table_prefix . 'bp_messages_notices';
 	$bp->messages->table_name_messages 		= $bp->table_prefix . 'bp_messages_messages';
 	$bp->messages->table_name_recipients 	= $bp->table_prefix . 'bp_messages_recipients';
+
+	// Notifications
 	$bp->messages->format_notification_function = 'messages_format_notifications';
 
@@ -38,10 +45,10 @@
 		$name = __('Messages <strong></strong>', 'buddypress');
 
-	/* Add 'Messages' to the main navigation */
+	// Add 'Messages' to the main navigation
 	bp_core_new_nav_item( array( 'name' => $name, 'slug' => $bp->messages->slug, 'position' => 50, 'show_for_displayed_user' => false, 'screen_function' => 'messages_screen_inbox', 'default_subnav_slug' => 'inbox', 'item_css_id' => $bp->messages->id ) );
 
 	$messages_link = $bp->loggedin_user->domain . $bp->messages->slug . '/';
 
-	/* Add the subnav items to the profile */
+	// Add the subnav items to the profile
 	bp_core_new_subnav_item( array( 'name' => __( 'Inbox', 'buddypress' ), 'slug' => 'inbox', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_inbox', 'position' => 10, 'user_has_access' => bp_is_my_profile() ) );
 	bp_core_new_subnav_item( array( 'name' => __( 'Sent Messages', 'buddypress' ), 'slug' => 'sentbox', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_sentbox', 'position' => 20, 'user_has_access' => bp_is_my_profile() ) );
@@ -170,12 +177,11 @@
 	global $bp;
 
-	$new_messages = get_user_meta( $bp->displayed_user->id, 'notification_messages_new_message', true );
-	if ( !$new_messages )
+	if ( !$new_messages = get_user_meta( $bp->displayed_user->id, 'notification_messages_new_message', true ) )
 		$new_messages = 'yes';
 
-	$new_notices = get_user_meta( $bp->displayed_user->id, 'notification_messages_new_notice', true );
-	if ( !$new_notices )
-		$new_notices = 'yes';
+	if ( !$new_notices = get_user_meta( $bp->displayed_user->id, 'notification_messages_new_notice', true ) )
+		$new_notices  = 'yes';
 ?>
+
 	<table class="notification-settings zebra" id="messages-notification-settings">
 		<thead>
@@ -205,4 +211,5 @@
 		</tbody>
 	</table>
+
 <?php
 }
@@ -229,11 +236,11 @@
 		bp_core_redirect( $bp->displayed_user->domain . $bp->current_component );
 
-	/* Check if a new reply has been submitted */
+	// Check if a new reply has been submitted
 	if ( isset( $_POST['send'] ) ) {
 
-		/* Check the nonce */
+		// Check the nonce
 		check_admin_referer( 'messages_send_message', 'send_message_nonce' );
 
-		/* Send the reply */
+		// Send the reply
 		if ( messages_new_message( array( 'thread_id' => $thread_id, 'subject' => $_POST['subject'], 'content' => $_POST['content'] ) ) )
 			bp_core_add_message( __( 'Your reply was sent successfully', 'buddypress' ) );
@@ -244,5 +251,5 @@
 	}
 
-	/* Mark message read */
+	// Mark message read
 	messages_mark_thread_read( $thread_id );
 
@@ -268,5 +275,5 @@
 			return false;
 
-		// delete message
+		// Delete message
 		if ( !messages_delete_thread($thread_id) ) {
 			bp_core_add_message( __('There was an error deleting that message.', 'buddypress'), 'error' );
@@ -293,9 +300,9 @@
 			return false;
 
-		if ( !messages_delete_thread( $thread_ids ) ) {
+		if ( !messages_delete_thread( $thread_ids ) )
 			bp_core_add_message( __('There was an error deleting messages.', 'buddypress'), 'error' );
-		} else {
+		else
 			bp_core_add_message( __('Messages deleted.', 'buddypress') );
-		}
+
 		bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
 	}
@@ -339,11 +346,11 @@
 	global $bp;
 
-	$defaults = array(
-		'thread_id' => false, // false for a new message, thread id for a reply to a thread.
-		'sender_id' => $bp->loggedin_user->id,
+	$defaults = array (
+		'sender_id'  => $bp->loggedin_user->id,
+		'thread_id'  => false, // false for a new message, thread id for a reply to a thread.
 		'recipients' => false, // Can be an array of usernames, user_ids or mixed.
-		'subject' => false,
-		'content' => false,
-		'date_sent' => bp_core_current_time()
+		'subject'    => false,
+		'content'    => false,
+		'date_sent'  => bp_core_current_time()
 	);
 
@@ -354,10 +361,10 @@
 		return false;
 
-	/* Create a new message object */
-	$message = new BP_Messages_Message;
+	// Create a new message object
+	$message            = new BP_Messages_Message;
 	$message->thread_id = $thread_id;
 	$message->sender_id = $sender_id;
-	$message->subject = $subject;
-	$message->message = $content;
+	$message->subject   = $subject;
+	$message->message   = $content;
 	$message->date_sent = $date_sent;
 
@@ -382,5 +389,5 @@
 			$message->subject = __( 'No Subject', 'buddypress' );
 
-		/* Loop the recipients and convert all usernames to user_ids where needed */
+		// Loop the recipients and convert all usernames to user_ids where needed
 		foreach( (array) $recipients as $recipient ) {
 			if ( is_numeric( trim( $recipient ) ) )
@@ -391,9 +398,9 @@
 		}
 
-		/* Strip the sender from the recipient list if they exist */
+		// Strip the sender from the recipient list if they exist
 		if ( $key = array_search( $sender_id, (array)$recipient_ids ) )
 			unset( $recipient_ids[$key] );
 
-		/* Remove duplicates */
+		// Remove duplicates
 		$recipient_ids = array_unique( (array)$recipient_ids );
 
@@ -401,5 +408,5 @@
 			return false;
 
-		/* Format this to match existing recipients */
+		// Format this to match existing recipients
 		foreach( (array)$recipient_ids as $i => $recipient_id ) {
 			$message->recipients[$i] = new stdClass;
@@ -430,9 +437,10 @@
 	if ( !is_super_admin() || empty( $subject ) || empty( $message ) ) {
 		return false;
+
+	// Has access to send notices, lets do it.
 	} else {
-		// Has access to send notices, lets do it.
-		$notice = new BP_Messages_Notice;
-		$notice->subject = $subject;
-		$notice->message = $message;
+		$notice            = new BP_Messages_Notice;
+		$notice->subject   = $subject;
+		$notice->message   = $message;
 		$notice->date_sent = bp_core_current_time();
 		$notice->is_active = 1;
@@ -470,5 +478,5 @@
 }
 
-function messages_check_thread_access( $thread_id, $user_id = false ) {
+function messages_check_thread_access( $thread_id, $user_id = 0 ) {
 	global $bp;
 
@@ -499,5 +507,5 @@
 }
 
-function messages_get_unread_count( $user_id = false ) {
+function messages_get_unread_count( $user_id = 0 ) {
 	global $bp;
 
@@ -529,12 +537,12 @@
 
 // List actions to clear super cached pages on, if super cache is installed
-add_action( 'messages_delete_thread', 'bp_core_clear_cache' );
-add_action( 'messages_send_notice', 'bp_core_clear_cache' );
-add_action( 'messages_message_sent', 'bp_core_clear_cache' );
+add_action( 'messages_delete_thread',  'bp_core_clear_cache' );
+add_action( 'messages_send_notice',    'bp_core_clear_cache' );
+add_action( 'messages_message_sent',   'bp_core_clear_cache' );
 
 // Don't cache message inbox/sentbox/compose as it's too problematic
 add_action( 'messages_screen_compose', 'bp_core_clear_cache' );
 add_action( 'messages_screen_sentbox', 'bp_core_clear_cache' );
-add_action( 'messages_screen_inbox', 'bp_core_clear_cache' );
+add_action( 'messages_screen_inbox',   'bp_core_clear_cache' );
 
 ?>
Index: /trunk/bp-themes/bp-default/groups/index.php
===================================================================
--- /trunk/bp-themes/bp-default/groups/index.php	(revision 3727)
+++ /trunk/bp-themes/bp-default/groups/index.php	(revision 3728)
@@ -5,5 +5,5 @@
 
 		<form action="" method="post" id="groups-directory-form" class="dir-form">
-			<h3><?php _e( 'Groups Directory', 'buddypress' ) ?><?php if ( is_user_logged_in() ) : ?> &nbsp;<a class="button" href="<?php echo bp_get_root_domain() . '/' . BP_GROUPS_SLUG . '/create/' ?>"><?php _e( 'Create a Group', 'buddypress' ) ?></a><?php endif; ?></h3>
+			<h3><?php _e( 'Groups Directory', 'buddypress' ) ?><?php if ( is_user_logged_in() ) : ?> &nbsp;<a class="button" href="<?php echo bp_get_root_domain() . '/' . bp_get_root_slug() . '/create/' ?>"><?php _e( 'Create a Group', 'buddypress' ) ?></a><?php endif; ?></h3>
 
 			<?php do_action( 'bp_before_directory_groups_content' ) ?>
Index: /trunk/bp-xprofile.php
===================================================================
--- /trunk/bp-xprofile.php	(revision 3727)
+++ /trunk/bp-xprofile.php	(revision 3728)
@@ -1,12 +1,12 @@
 <?php
-require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-admin.php' );
-require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-classes.php' );
-require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-filters.php' );
+
+// Required files
+require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-admin.php'       );
+require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-classes.php'      );
+require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-filters.php'      );
 require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-templatetags.php' );
-require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-cssjs.php' );
-
-/**
- * xprofile_setup_globals()
- *
+require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-cssjs.php'        );
+
+/**
  * Add the profile globals to the $bp global for use across the installation
  *
@@ -25,13 +25,16 @@
 		define ( 'BP_XPROFILE_SLUG', 'profile' );
 
-	/* Assign the base group and fullname field names to constants to use in SQL statements */
+	// Assign the base group and fullname field names to constants to use
+	// in SQL statements
 	define ( 'BP_XPROFILE_BASE_GROUP_NAME', stripslashes( $bp->site_options['bp-xprofile-base-group-name'] ) );
 	define ( 'BP_XPROFILE_FULLNAME_FIELD_NAME', stripslashes( $bp->site_options['bp-xprofile-fullname-field-name'] ) );
 
-	/* For internal identification */
+	// For internal identification
 	$bp->profile->id = 'profile';
 
+	// Slug
 	$bp->profile->slug = BP_XPROFILE_SLUG;
 
+	// Tables
 	$bp->profile->table_name_data   = $bp->table_prefix . 'bp_xprofile_data';
 	$bp->profile->table_name_groups = $bp->table_prefix . 'bp_xprofile_groups';
@@ -39,10 +42,11 @@
 	$bp->profile->table_name_meta	= $bp->table_prefix . 'bp_xprofile_meta';
 
+	// Notifications
 	$bp->profile->format_notification_function = 'xprofile_format_notifications';
 
-	/* Register this in the active components array */
+	// Register this in the active components array
 	$bp->active_components[$bp->profile->slug] = $bp->profile->id;
 
-	/* Set the support field type ids */
+	// Set the support field type ids
 	$bp->profile->field_types = apply_filters( 'xprofile_field_types', array( 'textbox', 'textarea', 'radio', 'checkbox', 'selectbox', 'multiselectbox', 'datebox' ) );
 
@@ -52,6 +56,4 @@
 
 /**
- * xprofile_add_admin_menu()
- *
  * Creates the administration interface menus and checks to see if the DB
  * tables are set up.
@@ -73,5 +75,5 @@
 		return false;
 
-	/* Add the administration tab under the "Site Admin" tab for site administrators */
+	// Add the administration tab under the "Site Admin" tab for site administrators
 	add_submenu_page( 'bp-general-settings', __( 'Profile Field Setup', 'buddypress' ), __( 'Profile Field Setup', 'buddypress' ), 'manage_options', 'bp-profile-setup', 'xprofile_admin' );
 }
@@ -79,6 +81,4 @@
 
 /**
- * xprofile_setup_nav()
- *
  * Sets up the navigation items for the xprofile component
  *
@@ -93,10 +93,10 @@
 	global $bp;
 
-	/* Add 'Profile' to the main navigation */
+	// Add 'Profile' to the main navigation
 	bp_core_new_nav_item( array( 'name' => __( 'Profile', 'buddypress' ), 'slug' => $bp->profile->slug, 'position' => 20, 'screen_function' => 'xprofile_screen_display_profile', 'default_subnav_slug' => 'public', 'item_css_id' => $bp->profile->id ) );
 
 	$profile_link = $bp->loggedin_user->domain . $bp->profile->slug . '/';
 
-	/* Add the subnav items to the profile */
+	// Add the subnav items to the profile
 	bp_core_new_subnav_item( array( 'name' => __( 'Public', 'buddypress' ), 'slug' => 'public', 'parent_url' => $profile_link, 'parent_slug' => $bp->profile->slug, 'screen_function' => 'xprofile_screen_display_profile', 'position' => 10 ) );
 	bp_core_new_subnav_item( array( 'name' => __( 'Edit Profile', 'buddypress' ), 'slug' => 'edit', 'parent_url' => $profile_link, 'parent_slug' => $bp->profile->slug, 'screen_function' => 'xprofile_screen_edit_profile', 'position' => 20 ) );
@@ -117,6 +117,4 @@
 
 /**
- * xprofile_setup_adminbar_menu()
- *
  * Adds an admin bar menu to any profile page providing site admin options for that user.
  *
@@ -130,8 +128,8 @@
 		return false;
 
-	/* Don't show this menu to non site admins or if you're viewing your own profile */
+	// Don't show this menu to non site admins or if you're viewing your own profile
 	if ( !is_super_admin() || bp_is_my_profile() )
-		return false;
-	?>
+		return false; ?>
+
 	<li id="bp-adminbar-adminoptions-menu">
 		<a href=""><?php _e( 'Admin Options', 'buddypress' ) ?></a>
@@ -142,7 +140,11 @@
 
 			<?php if ( !bp_core_is_user_spammer( $bp->displayed_user->id ) ) : ?>
+
 				<li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/mark-spammer/', 'mark-unmark-spammer' ) ?>" class="confirm"><?php _e( "Mark as Spammer", 'buddypress' ) ?></a></li>
+
 			<?php else : ?>
+
 				<li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/unmark-spammer/', 'mark-unmark-spammer' ) ?>" class="confirm"><?php _e( "Not a Spammer", 'buddypress' ) ?></a></li>
+
 			<?php endif; ?>
 
@@ -150,6 +152,8 @@
 
 			<?php do_action( 'xprofile_adminbar_menu_items' ) ?>
+
 		</ul>
 	</li>
+
 	<?php
 }
@@ -165,6 +169,4 @@
 
 /**
- * xprofile_screen_display_profile()
- *
  * Handles the display of the profile page by loading the correct template file.
  *
@@ -175,7 +177,8 @@
 	global $bp;
 
-	$new = '';
 	if ( isset( $_GET['new'] ) )
 		$new = $_GET['new'];
+	else
+		$new = '';
 
 	do_action( 'xprofile_screen_display_profile', $new );
@@ -184,6 +187,4 @@
 
 /**
- * xprofile_screen_edit_profile()
- *
  * Handles the display of the profile edit page by loading the correct template file.
  * Also checks to make sure this can only be accessed for the logged in users profile.
@@ -199,38 +200,40 @@
 		return false;
 
-	/* Make sure a group is set. */
+	// Make sure a group is set.
 	if ( empty( $bp->action_variables[1] ) )
 		bp_core_redirect( $bp->displayed_user->domain . BP_XPROFILE_SLUG . '/edit/group/1' );
 
-	/* Check the field group exists */
+	// Check the field group exists
 	if ( !xprofile_get_field_group( $bp->action_variables[1] ) )
 		bp_core_redirect( $bp->root_domain );
 
-	/* Check to see if any new information has been submitted */
+	// Check to see if any new information has been submitted
 	if ( isset( $_POST['field_ids'] ) ) {
 
-		/* Check the nonce */
+		// Check the nonce
 		check_admin_referer( 'bp_xprofile_edit' );
 
-		/* Check we have field ID's */
+		// Check we have field ID's
 		if ( empty( $_POST['field_ids'] ) )
 			bp_core_redirect( $bp->displayed_user->domain . BP_XPROFILE_SLUG . '/edit/group/' . $bp->action_variables[1] . '/' );
 
-		/* Explode the posted field IDs into an array so we know which fields have been submitted */
+		// Explode the posted field IDs into an array so we know which
+		// fields have been submitted
 		$posted_field_ids = explode( ',', $_POST['field_ids'] );
 
 		$is_required = array();
 
-		/* Loop through the posted fields formatting any datebox values then validate the field */
+		// Loop through the posted fields formatting any datebox values
+		// then validate the field
 		foreach ( (array)$posted_field_ids as $field_id ) {
 			if ( !isset( $_POST['field_' . $field_id] ) ) {
 
 				if ( !empty( $_POST['field_' . $field_id . '_day'] ) && is_numeric( $_POST['field_' . $field_id . '_day'] ) ) {
-					/* Concatenate the values. */
-					$date_value = $_POST['field_' . $field_id . '_day'] . ' ' .
-							      $_POST['field_' . $field_id . '_month'] . ' ' .
-								  $_POST['field_' . $field_id . '_year'];
-
-					/* Turn the concatenated value into a timestamp */
+					// Concatenate the values
+					$date_value =   $_POST['field_' . $field_id . '_day'] . ' ' .
+									$_POST['field_' . $field_id . '_month'] . ' ' .
+									$_POST['field_' . $field_id . '_year'];
+
+					// Turn the concatenated value into a timestamp
 					$_POST['field_' . $field_id] = strtotime( $date_value );
 				}
@@ -246,8 +249,8 @@
 			bp_core_add_message( __( 'Please make sure you fill in all required fields in this profile field group before saving.', 'buddypress' ), 'error' );
 		else {
-			/* Reset the errors var */
+			// Reset the errors var
 			$errors = false;
 
-			/* Now we've checked for required fields, lets save the values. */
+			// Now we've checked for required fields, lets save the values.
 			foreach ( (array)$posted_field_ids as $field_id ) {
 				
@@ -266,5 +269,5 @@
 			do_action( 'xprofile_updated_profile', $bp->displayed_user->id, $posted_field_ids, $errors );
 
-			/* Set the feedback messages */
+			// Set the feedback messages
 			if ( $errors )
 				bp_core_add_message( __( 'There was a problem updating some of your profile information, please try again.', 'buddypress' ), 'error' );
@@ -272,5 +275,5 @@
 				bp_core_add_message( __( 'Changes saved.', 'buddypress' ) );
 
-			/* Redirect back to the edit screen to display the updates and message */
+			// Redirect back to the edit screen to display the updates and message
 			bp_core_redirect( $bp->displayed_user->domain . BP_XPROFILE_SLUG . '/edit/group/' . $bp->action_variables[1] . '/' );
 		}
@@ -282,6 +285,4 @@
 
 /**
- * xprofile_screen_change_avatar()
- *
  * Handles the uploading and cropping of a user avatar. Displays the change avatar page.
  *
@@ -300,20 +301,20 @@
 	if ( !empty( $_FILES ) ) {
 
-		/* Check the nonce */
+		// Check the nonce
 		check_admin_referer( 'bp_avatar_upload' );
 
-		/* Pass the file to the avatar upload handler */
+		// Pass the file to the avatar upload handler
 		if ( bp_core_avatar_handle_upload( $_FILES, 'xprofile_avatar_upload_dir' ) ) {
 			$bp->avatar_admin->step = 'crop-image';
 
-			/* Make sure we include the jQuery jCrop file for image cropping */
+			// Make sure we include the jQuery jCrop file for image cropping
 			add_action( 'wp_print_scripts', 'bp_core_add_jquery_cropper' );
 		}
 	}
 
-	/* If the image cropping is done, crop the image and save a full/thumb version */
+	// If the image cropping is done, crop the image and save a full/thumb version
 	if ( isset( $_POST['avatar-crop-submit'] ) ) {
 
-		/* Check the nonce */
+		// Check the nonce
 		check_admin_referer( 'bp_avatar_cropstore' );
 
@@ -340,6 +341,4 @@
 
 /**
- * xprofile_action_delete_avatar()
- *
  * This function runs when an action is set for a screen:
  * example.com/members/andy/profile/change-avatar/ [delete-avatar]
@@ -359,5 +358,5 @@
 		return false;
 
-	/* Check the nonce */
+	// Check the nonce
 	check_admin_referer( 'bp_delete_avatar_link' );
 
@@ -387,7 +386,7 @@
 		return false;
 
-	/* Register the activity stream actions for this component */
-	bp_activity_set_action( $bp->profile->id, 'new_member', __( 'New member registered', 'buddypress' ) );
-	bp_activity_set_action( $bp->profile->id, 'updated_profile', __( 'Updated Profile', 'buddypress' ) );
+	// Register the activity stream actions for this component
+	bp_activity_set_action( $bp->profile->id, 'new_member',      __( 'New member registered', 'buddypress' ) );
+	bp_activity_set_action( $bp->profile->id, 'updated_profile', __( 'Updated Profile',       'buddypress' ) );
 
 	do_action( 'xprofile_register_activity_actions' );
@@ -396,6 +395,4 @@
 
 /**
- * xprofile_record_activity()
- *
  * Records activity for the logged in user within the profile component so that
  * it will show in the users activity stream (if installed)
@@ -412,15 +409,15 @@
 		return false;
 
-	$defaults = array(
-		'user_id' => $bp->loggedin_user->id,
-		'action' => '',
-		'content' => '',
-		'primary_link' => '',
-		'component' => $bp->profile->id,
-		'type' => false,
-		'item_id' => false,
+	$defaults = array (
+		'user_id'           => $bp->loggedin_user->id,
+		'action'            => '',
+		'content'           => '',
+		'primary_link'      => '',
+		'component'         => $bp->profile->id,
+		'type'              => false,
+		'item_id'           => false,
 		'secondary_item_id' => false,
-		'recorded_time' => bp_core_current_time(),
-		'hide_sitewide' => false
+		'recorded_time'     => bp_core_current_time(),
+		'hide_sitewide'     => false
 	);
 
@@ -432,6 +429,4 @@
 
 /**
- * xprofile_delete_activity()
- *
  * Deletes activity for a user within the profile component so that
  * it will be removed from the users activity stream and sitewide stream (if installed)
@@ -446,5 +441,5 @@
 
 	if ( function_exists('bp_activity_delete_by_item_id') ) {
-		extract($args);
+		extract( $args );
 		bp_activity_delete_by_item_id( array( 'item_id' => $item_id, 'component' => $bp->profile->id, 'type' => $type, 'user_id' => $user_id, 'secondary_item_id' => $secondary_item_id ) );
 	}
@@ -475,7 +470,7 @@
 	$defaults = array(
 		'field_group_id' => false,
-		'name' => false,
-		'description' => '',
-		'can_delete' => true
+		'name'           => false,
+		'description'    => '',
+		'can_delete'     => true
 	);
 
@@ -486,8 +481,8 @@
 		return false;
 
-	$field_group = new BP_XProfile_Group( $field_group_id );
-	$field_group->name = $name;
+	$field_group              = new BP_XProfile_Group( $field_group_id );
+	$field_group->name        = $name;
 	$field_group->description = $description;
-	$field_group->can_delete = $can_delete;
+	$field_group->can_delete  = $can_delete;
 
 	return $field_group->save();
@@ -536,13 +531,13 @@
 	 */
 
-	/* Check we have the minimum details */
+	// Check we have the minimum details
 	if ( !$field_group_id )
 		return false;
 
-	/* Check this is a valid field type */
+	// Check this is a valid field type
 	if ( !in_array( $type, (array) $bp->profile->field_types ) )
 		return false;
 
-	/* Instantiate a new field object */
+	// Instantiate a new field object
 	if ( $field_id )
 		$field = new BP_XProfile_Field( $field_id );
@@ -601,6 +596,4 @@
 
 /**
- * xprofile_get_field_data()
- *
  * Fetches profile data for a specific field for the user.
  *
@@ -615,5 +608,5 @@
  * @return mixed The profile field data.
  */
-function xprofile_get_field_data( $field, $user_id = null ) {
+function xprofile_get_field_data( $field, $user_id = 0 ) {
 	global $bp;
 
@@ -622,8 +615,8 @@
 		xprofile_setup_globals();
 
-	if ( !$user_id )
+	if ( empty( $user_id ) )
 		$user_id = $bp->displayed_user->id;
 
-	if ( !$user_id )
+	if ( empty( $user_id ) )
 		return false;
 
@@ -633,5 +626,5 @@
 		$field_id = xprofile_get_field_id_from_name( $field );
 
-	if ( !$field_id )
+	if ( empty( $field_id ) )
 		return false;
 
@@ -651,6 +644,4 @@
 
 /**
- * xprofile_set_field_data()
- *
  * A simple function to set profile data for a specific field for a specific user.
  *
@@ -669,5 +660,5 @@
 		$field_id = xprofile_get_field_id_from_name( $field );
 
-	if ( !$field_id )
+	if ( empty( $field_id ) )
 		return false;
 
@@ -684,5 +675,5 @@
 	}
 
-	/* Check the value is an acceptable value */
+	// Check the value is an acceptable value
 	if ( 'checkbox' == $field->type || 'radio' == $field->type || 'selectbox' == $field->type || 'multiselectbox' == $field->type ) {
 		$options = $field->get_children();
@@ -697,5 +688,5 @@
 			}
 
-			/* Reset the keys by merging with an empty array */
+			// Reset the keys by merging with an empty array
 			$value = array_merge( array(), $value );
 		} else {
@@ -705,8 +696,8 @@
 	}
 
-	$field = new BP_XProfile_ProfileData();
+	$field           = new BP_XProfile_ProfileData();
 	$field->field_id = $field_id;
-	$field->user_id = $user_id;
-	$field->value = maybe_serialize( $value );
+	$field->user_id  = $user_id;
+	$field->value    = maybe_serialize( $value );
 
 	return $field->save();
@@ -736,6 +727,4 @@
 
 /**
- * xprofile_get_field_id_from_name()
- *
  * Returns the ID for the field based on the field name.
  *
@@ -749,6 +738,4 @@
 
 /**
- * xprofile_get_random_profile_data()
- *
  * Fetches a random piece of profile data for the user.
  *
@@ -763,5 +750,5 @@
  */
 function xprofile_get_random_profile_data( $user_id, $exclude_fullname = true ) {
-	$field_data = BP_XProfile_ProfileData::get_random( $user_id, $exclude_fullname );
+	$field_data           = BP_XProfile_ProfileData::get_random( $user_id, $exclude_fullname );
 	$field_data[0]->value = xprofile_format_profile_field( $field_data[0]->type, $field_data[0]->value );
 
@@ -773,6 +760,4 @@
 
 /**
- * xprofile_format_profile_field()
- *
  * Formats a profile field according to its type. [ TODO: Should really be moved to filters ]
  *
@@ -784,5 +769,5 @@
  */
 function xprofile_format_profile_field( $field_type, $field_value ) {
-	if ( !isset($field_value) || empty( $field_value ) )
+	if ( !isset( $field_value ) || empty( $field_value ) )
 		return false;
 
@@ -793,5 +778,5 @@
 	} else {
 		$content = $field_value;
-		$field_value = str_replace(']]>', ']]&gt;', $content);
+		$field_value = str_replace( ']]>', ']]&gt;', $content );
 	}
 
@@ -804,6 +789,4 @@
 
 /**
- * xprofile_avatar_upload_dir()
- *
  * Setup the avatar upload directory for a user.
  *
@@ -813,14 +796,14 @@
  * @return array() containing the path and URL plus some other settings.
  */
-function xprofile_avatar_upload_dir( $directory = false, $user_id = false ) {
-	global $bp;
-
-	if ( !$user_id )
+function xprofile_avatar_upload_dir( $directory = false, $user_id = 0 ) {
+	global $bp;
+
+	if ( empty( $user_id ) )
 		$user_id = $bp->displayed_user->id;
 
-	if ( !$directory )
+	if ( empty( $directory ) )
 		$directory = 'avatars';
 
-	$path  = BP_AVATAR_UPLOAD_PATH . '/avatars/' . $user_id;
+	$path    = BP_AVATAR_UPLOAD_PATH . '/avatars/' . $user_id;
 	$newbdir = $path;
 
@@ -828,6 +811,6 @@
 		@wp_mkdir_p( $path );
 
-	$newurl  = BP_AVATAR_URL . '/avatars/' . $user_id;
-	$newburl = $newurl;
+	$newurl    = BP_AVATAR_URL . '/avatars/' . $user_id;
+	$newburl   = $newurl;
 	$newsubdir = '/avatars/' . $user_id;
 
@@ -836,11 +819,9 @@
 
 /**
- * xprofile_sync_wp_profile()
- *
  * Syncs Xprofile data to the standard built in WordPress profile data.
  *
  * @package BuddyPress Core
  */
-function xprofile_sync_wp_profile( $user_id = false ) {
+function xprofile_sync_wp_profile( $user_id = 0 ) {
 	global $bp, $wpdb;
 
@@ -862,10 +843,10 @@
 	} else {
 		$firstname = substr( $fullname, 0, $space );
-		$lastname = trim( substr( $fullname, $space, strlen($fullname) ) );
-	}
-
-	update_user_meta( $user_id, 'nickname', $fullname );
+		$lastname = trim( substr( $fullname, $space, strlen( $fullname ) ) );
+	}
+
+	update_user_meta( $user_id, 'nickname',   $fullname  );
 	update_user_meta( $user_id, 'first_name', $firstname );
-	update_user_meta( $user_id, 'last_name', $lastname );
+	update_user_meta( $user_id, 'last_name',  $lastname  );
 
 	$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET display_name = %s WHERE ID = %d", $fullname, $user_id ) );
@@ -876,6 +857,5 @@
 
 
-/* xprofile_sync_bp_profile()
- *
+/**
  * Syncs the standard built in WordPress profile data to XProfile.
  *
@@ -895,6 +875,4 @@
 
 /**
- * xprofile_remove_data_on_user_deletion()
- *
  * When a user is deleted, we need to clean up the database and remove all the
  * profile data from each table. Also we need to clean anything up in the usermeta table
@@ -915,11 +893,11 @@
 
 	// unset the usermeta for avatars from the usermeta table.
-	delete_user_meta( $user_id, 'bp_core_avatar_v1' );
+	delete_user_meta( $user_id, 'bp_core_avatar_v1'      );
 	delete_user_meta( $user_id, 'bp_core_avatar_v1_path' );
-	delete_user_meta( $user_id, 'bp_core_avatar_v2' );
+	delete_user_meta( $user_id, 'bp_core_avatar_v2'      );
 	delete_user_meta( $user_id, 'bp_core_avatar_v2_path' );
 }
-add_action( 'wpmu_delete_user', 'xprofile_remove_data' );
-add_action( 'delete_user', 'xprofile_remove_data' );
+add_action( 'wpmu_delete_user',  'xprofile_remove_data' );
+add_action( 'delete_user',       'xprofile_remove_data' );
 add_action( 'bp_make_spam_user', 'xprofile_remove_data' );
 
@@ -1071,6 +1049,6 @@
 // List actions to clear object caches on
 add_action( 'xprofile_groups_deleted_group', 'xprofile_clear_profile_groups_object_cache' );
-add_action( 'xprofile_groups_saved_group', 'xprofile_clear_profile_groups_object_cache' );
-add_action( 'xprofile_updated_profile', 'xprofile_clear_profile_data_object_cache' );
+add_action( 'xprofile_groups_saved_group',   'xprofile_clear_profile_groups_object_cache' );
+add_action( 'xprofile_updated_profile',      'xprofile_clear_profile_data_object_cache'   );
 
 // List actions to clear super cached pages on, if super cache is installed
