Index: bbp-includes/bbp-general-functions.php
===================================================================
--- bbp-includes/bbp-general-functions.php	(revision 2961)
+++ bbp-includes/bbp-general-functions.php	(working copy)
@@ -115,14 +115,13 @@
 
 /**
  * The plugin version of bbPress comes with two topic display options:
- *     ~ Traditional - Topics are included in the reply loop (default)
- *     ~ New Style   - Topics appear as "lead" posts, ahead of replies
+ * - Traditional: Topics are included in the reply loop (default)
+ * - New Style: Topics appear as "lead" posts, ahead of replies
  *
  * @since bbPress (r2954)
  *
- * @global obj $bbp
  * @param $show_lead Optional. Default false
- * @return bool
+ * @return bool Yes if the topic appears as a lead, otherwise false
  */
 function bbp_show_lead_topic( $show_lead = false ) {
 	return apply_filters( 'bbp_show_lead_topic', (bool) $show_lead );
@@ -157,8 +156,11 @@
 /**
  * Append 'view=all' to query string if it's already there from referer
  *
- * @param string $original_link
- * @return <type>
+ * @param string $original_link Original Link to be modified
+ * @uses current_user_can() To check if the current user can moderate
+ * @uses add_query_arg() To add args to the url
+ * @uses apply_filters() Calls 'bbp_add_view_all' with the link and original link
+ * @return string The link with 'view=all' appended if necessary
  */
 function bbp_add_view_all( $original_link ) {
 
@@ -201,6 +203,8 @@
  *
  * @param array $data Post data
  * @param array $postarr Original post array (includes post id)
+ * @uses bbp_get_topic_post_type() To get the topic post type
+ * @uses bbp_get_reply_post_type() To get the reply post type
  * @uses bbp_is_topic_anonymous() To check if the topic is by an anonymous user
  * @uses bbp_is_reply_anonymous() To check if the reply is by an anonymous user
  * @return array Data
@@ -258,6 +262,9 @@
  *  - count_tags: Count tags? If set to false, empty tags are also not counted
  *  - count_empty_tags: Count empty tags?
  * @uses bbp_count_users() To count the number of registered users
+ * @uses bbp_get_forum_post_type() To get the forum post type
+ * @uses bbp_get_topic_post_type() To get the topic post type
+ * @uses bbp_get_reply_post_type() To get the reply post type
  * @uses wp_count_posts() To count the number of forums, topics and replies
  * @uses wp_count_terms() To count the number of topic tags
  * @uses current_user_can() To check if the user is capable of doing things
@@ -536,10 +543,10 @@
 
 	// Assign variables
 	$defaults = array (
-		'bbp_anonymous_name'    => $_POST['bbp_anonymous_name'],
-		'bbp_anonymous_email'   => $_POST['bbp_anonymous_email'],
-		'bbp_anonymous_website' => $_POST['bbp_anonymous_website'],
-		'bbp_anonymous_ip'      => $_SERVER['REMOTE_ADDR']
+		'bbp_anonymous_name'    => isset( $_POST['bbp_anonymous_name']    ) ? $_POST['bbp_anonymous_name']    : false,
+		'bbp_anonymous_email'   => isset( $_POST['bbp_anonymous_email']   ) ? $_POST['bbp_anonymous_email']   : false,
+		'bbp_anonymous_website' => isset( $_POST['bbp_anonymous_website'] ) ? $_POST['bbp_anonymous_website'] : false,
+		'bbp_anonymous_ip'      => isset( $_SERVER['REMOTE_ADDR']         ) ? $_SERVER['REMOTE_ADDR']         : false
 	);
 
 	$r = wp_parse_args( $args, $defaults );
@@ -679,9 +686,22 @@
  * @since bbPress (r2753)
  *
  * @uses bbp_is_user_profile_page() To check if it's a profile page
+ * @uses apply_filters() Calls 'bbp_profile_templates' with the profile
+ *                        templates array
  * @uses bbp_is_user_profile_edit() To check if it's a profile edit page
+ * @uses apply_filters() Calls 'bbp_profile_edit_templates' with the profile
+ *                        edit templates array
+ * @uses bbp_is_view() To check if it's a view page
+ * @uses bbp_get_view_id() To get the view id
+ * @uses apply_filters() Calls 'bbp_view_templates' with the view templates array
  * @uses bbp_is_topic_edit() To check if it's a topic edit page
+ * @uses bbp_get_topic_post_type() To get the topic post type
+ * @uses apply_filters() Calls 'bbp_topic_edit_templates' with the topic edit
+ *                        templates array
  * @uses bbp_is_reply_edit() To check if it's a reply edit page
+ * @uses bbp_get_reply_post_type() To get the reply post type
+ * @uses apply_filters() Calls 'bbp_reply_edit_templates' with the reply edit
+ *                        templates array
  * @uses apply_filters() Calls 'bbp_custom_template' with the template array
  * @uses bbp_load_template() To load the template
  */
@@ -706,6 +726,7 @@
 			'forums/user-edit.php',
 			'bbpress/user-edit.php',
 			'user-edit.php',
+			'forums/user.php',
 			'bbpress/user.php',
 			'user.php',
 			'author.php',
@@ -716,8 +737,8 @@
 	} elseif ( bbp_is_view() ) {
 		$template = apply_filters( 'bbp_view_templates', array(
 			'forums/view-' . bbp_get_view_id(),
+			'bbpress/view-' . bbp_get_view_id(),
 			'forums/view.php',
-			'bbpress/view-' . bbp_get_view_id(),
 			'bbpress/view.php',
 			'view-' . bbp_get_view_id(),
 			'view.php',
@@ -728,8 +749,8 @@
 	} elseif ( bbp_is_topic_edit() ) {
 		$template = array(
 			'forums/action-edit.php',
+			'bbpress/action-edit.php',
 			'forums/single-' . bbp_get_topic_post_type(),
-			'bbpress/action-edit.php',
 			'bbpress/single-' . bbp_get_topic_post_type(),
 			'action-bbp-edit.php',
 			'single-' . bbp_get_topic_post_type(),
@@ -739,11 +760,11 @@
 
 		// Add split/merge to front of array if present in _GET
 		if ( !empty( $_GET['action'] ) && in_array( $_GET['action'], array( 'merge', 'split' ) ) ) {
-			array_unshift( $template, array(
+			array_unshift( $template,
 				'forums/action-split-merge.php',
 				'bbpress/action-split-merge.php',
-				'action-bbp-split-merge.php'
-			) );
+				'action-split-merge.php'
+			);
 		}
 
 		$template = apply_filters( 'bbp_topic_edit_templates', $template );
@@ -752,8 +773,8 @@
 	} elseif ( bbp_is_reply_edit() ) {
 		$template = apply_filters( 'bbp_reply_edit_templates', array(
 			'forums/action-edit.php',
+			'bbpress/action-edit.php',
 			'forums/single-' . bbp_get_reply_post_type(),
-			'bbpress/action-edit.php',
 			'bbpress/single-' . bbp_get_reply_post_type(),
 			'action-bbp-edit.php',
 			'single-' . bbp_get_reply_post_type(),
@@ -810,12 +831,19 @@
  * @since bbPress (r2688)
  *
  * @uses get_query_var() To get {@link WP_Query} query var
+ * @uses is_email() To check if the string is an email
+ * @uses get_user_by() To try to get the user by email and nicename
  * @uses WP_User to get the user data
  * @uses WP_Query::set_404() To set a 404 status
- * @uses is_multisite() To check if it's a multisite
  * @uses current_user_can() To check if the current user can edit the user
  * @uses apply_filters() Calls 'enable_edit_any_user_configuration' with true
  * @uses wp_die() To die
+ * @uses bbp_get_query_name() To get the query name and check if it's 'bbp_widget'
+ * @uses bbp_get_view_query_args() To get the view query args
+ * @uses bbp_get_topic_post_type() To get the topic post type
+ * @uses bbp_get_reply_post_type() To get the reply post type
+ * @uses is_multisite() To check if it's a multisite
+ * @uses remove_action() To remove the auto save post revision action
  */
 function bbp_pre_get_posts( $wp_query ) {
 	global $bbp, $wp_version;
@@ -929,8 +957,19 @@
  * @param string $seplocation Optional. Direction to display title, 'right'.
  * @uses bbp_is_user_profile_page() To check if it's a user profile page
  * @uses bbp_is_user_profile_edit() To check if it's a user profile edit page
+ * @uses bbp_is_user_home() To check if the profile page is of the current user
  * @uses get_query_var() To get the user id
  * @uses get_userdata() To get the user data
+ * @uses bbp_is_forum() To check if it's a forum
+ * @uses bbp_get_forum_title() To get the forum title
+ * @uses bbp_is_topic() To check if it's a topic
+ * @uses bbp_get_topic_title() To get the topic title
+ * @uses bbp_is_reply() To check if it's a reply
+ * @uses bbp_get_reply_title() To get the reply title
+ * @uses is_tax() To check if it's the tag page
+ * @uses get_queried_object() To get the queried object
+ * @uses bbp_is_view() To check if it's a view
+ * @uses bbp_get_view_title() To get the view title
  * @uses apply_filters() Calls 'bbp_raw_title' with the title
  * @uses apply_filters() Calls 'bbp_profile_page_wp_title' with the title,
  *                        separator and separator location
@@ -1138,8 +1177,10 @@
 	if ( empty( $redirect_to ) )
 		$redirect_to = home_url( isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : '' );
 
-	$url = add_query_arg( array( 'redirect_to' => esc_url( $redirect_to ) ), $url );
+	$redirect_to = esc_url( add_query_arg( array( 'loggedout' => '1' ), $redirect_to ) );
 
+	$url = add_query_arg( array( 'redirect_to' => $redirect_to ), $url );
+
 	return apply_filters( 'bbp_logout_url', $url, $redirect_to );
 }
 
@@ -1148,9 +1189,15 @@
 /**
  * Query the DB and get the last public post_id that has parent_id as post_parent
  *
- * @global db $wpdb
- * @param int $parent_id
- * @param string $post_type
+ * @param int $parent_id Parent id
+ * @param string $post_type Post type. Defaults to 'post'
+ * @uses bbp_get_topic_post_type() To get the topic post type
+ * @uses wp_cache_get() To check if there is a cache of the last child id
+ * @uses wpdb::prepare() To prepare the query
+ * @uses wpdb::get_var() To get the result of the query in a variable
+ * @uses wp_cache_set() To set the cache for future use
+ * @uses apply_filters() Calls 'bbp_get_public_child_last_id' with the child
+ *                        id, parent id and post type
  * @return int The last active post_id
  */
 function bbp_get_public_child_last_id( $parent_id = 0, $post_type = 'post' ) {
@@ -1160,10 +1207,16 @@
 		return false;
 
 	// The ID of the cached query
-	$cache_id = 'bbp_parent_' . $parent_id . '_type_' . $post_type . '_child_last_id';
+	$cache_id    = 'bbp_parent_' . $parent_id . '_type_' . $post_type . '_child_last_id';
+	$post_status = array( 'publish' );
 
+	if ( $post_type == bbp_get_topic_post_type() )
+		$post_status[] = $bbp->closed_status_id;
+
+	$post_status = "'" . join( "', '", $post_status ) . "'";
+
 	if ( !$child_id = wp_cache_get( $cache_id, 'bbpress' ) ) {
-		$child_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent = %d AND post_status = 'publish' AND post_type = '%s' ORDER BY ID DESC LIMIT 1;", $parent_id, $post_type ) );
+		$child_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( {$post_status} ) AND post_type = '%s' ORDER BY ID DESC LIMIT 1;", $parent_id, $post_type ) );
 		wp_cache_set( $cache_id, $child_id, 'bbpress' );
 	}
 
@@ -1173,9 +1226,15 @@
 /**
  * Query the DB and get a count of public children
  *
- * @global db $wpdb
- * @param int $parent_id
- * @param string $post_type
+ * @param int $parent_id Parent id
+ * @param string $post_type Post type. Defaults to 'post'
+ * @uses bbp_get_topic_post_type() To get the topic post type
+ * @uses wp_cache_get() To check if there is a cache of the children count
+ * @uses wpdb::prepare() To prepare the query
+ * @uses wpdb::get_var() To get the result of the query in a variable
+ * @uses wp_cache_set() To set the cache for future use
+ * @uses apply_filters() Calls 'bbp_get_public_child_count' with the child
+ *                        count, parent id and post type
  * @return int The number of children
  */
 function bbp_get_public_child_count( $parent_id = 0, $post_type = 'post' ) {
@@ -1185,10 +1244,16 @@
 		return false;
 
 	// The ID of the cached query
-	$cache_id = 'bbp_parent_' . $parent_id . '_type_' . $post_type . '_child_count';
+	$cache_id    = 'bbp_parent_' . $parent_id . '_type_' . $post_type . '_child_count';
+	$post_status = array( 'publish' );
 
+	if ( $post_type == bbp_get_topic_post_type() )
+		$post_status[] = $bbp->closed_status_id;
+
+	$post_status = "'" . join( "', '", $post_status ) . "'";
+
 	if ( !$child_count = wp_cache_get( $cache_id, 'bbpress' ) ) {
-		$child_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( '" . join( "', '", array( 'publish', $bbp->closed_status_id ) ) . "' ) AND post_type = '%s';", $parent_id, $post_type ) );
+		$child_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( {$post_status} ) AND post_type = '%s';", $parent_id, $post_type ) );
 		wp_cache_set( $cache_id, $child_count, 'bbpress' );
 	}
 
@@ -1196,12 +1261,18 @@
 }
 
 /**
- * Query the DB and get a the child ID's of public children
+ * Query the DB and get a the child id's of public children
  *
- * @global db $wpdb
- * @param int $parent_id
- * @param string $post_type
- * @return int The number of children
+ * @param int $parent_id Parent id
+ * @param string $post_type Post type. Defaults to 'post'
+ * @uses bbp_get_topic_post_type() To get the topic post type
+ * @uses wp_cache_get() To check if there is a cache of the children
+ * @uses wpdb::prepare() To prepare the query
+ * @uses wpdb::get_col() To get the result of the query in an array
+ * @uses wp_cache_set() To set the cache for future use
+ * @uses apply_filters() Calls 'bbp_get_public_child_ids' with the child ids,
+ *                        parent id and post type
+ * @return array The array of children
  */
 function bbp_get_public_child_ids( $parent_id = 0, $post_type = 'post' ) {
 	global $wpdb, $bbp;
@@ -1210,10 +1281,16 @@
 		return false;
 
 	// The ID of the cached query
-	$cache_id = 'bbp_parent_' . $parent_id . '_type_' . $post_type . '_child_ids';
+	$cache_id    = 'bbp_parent_' . $parent_id . '_type_' . $post_type . '_child_ids';
+	$post_status = array( 'publish' );
 
+	if ( $post_type == bbp_get_topic_post_type() )
+		$post_status[] = $bbp->closed_status_id;
+
+	$post_status = "'" . join( "', '", $post_status ) . "'";
+
 	if ( !$child_ids = wp_cache_get( $cache_id, 'bbpress' ) ) {
-		$child_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( '" . join( "', '", array( 'publish', $bbp->closed_status_id ) ) . "' ) AND post_type = '%s' ORDER BY ID DESC;", $parent_id, $post_type ) );
+		$child_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( {$post_status} ) AND post_type = '%s' ORDER BY ID DESC;", $parent_id, $post_type ) );
 		wp_cache_set( $cache_id, $child_ids, 'bbpress' );
 	}
 
Index: bbp-includes/bbp-general-template.php
===================================================================
--- bbp-includes/bbp-general-template.php	(revision 2961)
+++ bbp-includes/bbp-general-template.php	(working copy)
@@ -38,10 +38,12 @@
  *
  * @since bbPress (r2549)
  *
- * @uses WP_Query
- *
  * @param int $post_id Possible post_id to check
- * @return bool
+ * @uses bbp_get_forum_post_type() To get the forum post type
+ * @uses is_singular() To check if it's the single post page
+ * @uses get_post_field() To get the post type of the post id
+ * @uses WP_Query To make some checks
+ * @return bool True if it's a forum page, false if not
  */
 function bbp_is_forum( $post_id = 0 ) {
 	global $wp_query, $bbp;
@@ -68,11 +70,13 @@
  *
  * @since bbPress (r2549)
  *
- * @uses WP_Query
- * @uses bbp_is_topic_edit() To check if it's a topic edit page
- *
  * @param int $post_id Possible post_id to check
- * @return bool
+ * @uses bbp_is_topic_edit() To return false if it's a topic edit page
+ * @uses bbp_get_topic_post_type() To get the topic post type
+ * @uses is_singular() To check if it's the single post page
+ * @uses get_post_field() To get the post type of the post id
+ * @uses WP_Query To make some checks
+ * @return bool True if it's a topic page, false if not
  */
 function bbp_is_topic( $post_id = 0 ) {
 	global $wp_query, $bbp;
@@ -104,7 +108,7 @@
  * @since bbPress (r2753)
  *
  * @uses WP_Query Checks if WP_Query::bbp_is_topic_edit is true
- * @return bool
+ * @return bool True if it's the topic edit page, false if not
  */
 function bbp_is_topic_edit() {
 	global $wp_query;
@@ -121,7 +125,7 @@
  * @since bbPress (r2756)
  *
  * @uses bbp_is_topic_edit() To check if it's a topic edit page
- * @return bool
+ * @return bool True if it's the topic merge page, false if not
  */
 function bbp_is_topic_merge() {
 
@@ -137,7 +141,7 @@
  * @since bbPress (r2756)
  *
  * @uses bbp_is_topic_edit() To check if it's a topic edit page
- * @return bool
+ * @return bool True if it's the topic split page, false if not
  */
 function bbp_is_topic_split() {
 
@@ -147,16 +151,19 @@
 	return false;
 }
 
+
 /**
  * Check if current page is a bbPress reply
  *
  * @since bbPress (r2549)
  *
- * @uses WP_Query
- * @uses bbp_is_reply_edit() To check if it's a reply edit page
- *
  * @param int $post_id Possible post_id to check
- * @return bool
+ * @uses bbp_is_reply_edit() To return false if it's a reply edit page
+ * @uses bbp_get_reply_post_type() To get the reply post type
+ * @uses is_singular() To check if it's the single post page
+ * @uses get_post_field() To get the post type of the post id
+ * @uses WP_Query To make some checks
+ * @return bool True if it's a reply page, false if not
  */
 function bbp_is_reply( $post_id = 0 ) {
 	global $wp_query, $bbp;
@@ -188,7 +195,7 @@
  * @since bbPress (r2753)
  *
  * @uses WP_Query Checks if WP_Query::bbp_is_reply_edit is true
- * @return bool
+ * @return bool True if it's the reply edit page, false if not
  */
 function bbp_is_reply_edit() {
 	global $wp_query;
@@ -210,7 +217,7 @@
  *                                to true.
  * @uses bbp_is_user_profile_page() To check if it's the user profile page
  * @uses bbp_get_query_name() To get the query name
- * @return bool
+ * @return bool True if it's the favorites page, false if not
  */
 function bbp_is_favorites( $query_name_check = true ) {
 	if ( !bbp_is_user_profile_page() )
@@ -233,7 +240,7 @@
  *                                to true.
  * @uses bbp_is_user_profile_page() To check if it's the user profile page
  * @uses bbp_get_query_name() To get the query name
- * @return bool
+ * @return bool True if it's the subscriptions page, false if not
  */
 function bbp_is_subscriptions( $query_name_check = true ) {
 	if ( !bbp_is_user_profile_page() )
@@ -257,7 +264,7 @@
  *                                to true.
  * @uses bbp_is_user_profile_page() To check if it's the user profile page
  * @uses bbp_get_query_name() To get the query name
- * @return bool
+ * @return bool True if it's the topics created page, false if not
  */
 function bbp_is_topics_created( $query_name_check = true ) {
 	if ( !bbp_is_user_profile_page() )
@@ -275,7 +282,7 @@
  * @uses bbPres Checks if bbPress::displayed_user is set and if
  *               bbPress::displayed_user::ID equals bbPress::current_user::ID
  *               or not
- * @return bool
+ * @return bool True if it's the user's home, false if not
  */
 function bbp_is_user_home() {
 	global $bbp;
@@ -292,7 +299,7 @@
  * @since bbPress (r2688)
  *
  * @uses WP_Query Checks if WP_Query::bbp_is_user_profile_page is set to true
- * @return bool
+ * @return bool True if it's a user's profile page, false if not
  */
 function bbp_is_user_profile_page() {
 	global $wp_query;
@@ -309,7 +316,7 @@
  * @since bbPress (r2688)
  *
  * @uses WP_Query Checks if WP_Query::bbp_is_user_profile_edit is set to true
- * @return bool
+ * @return bool True if it's a user's profile edit page, false if not
  */
 function bbp_is_user_profile_edit() {
 	global $wp_query;
@@ -360,8 +367,7 @@
  * @uses bbp_is_subscriptions()
  * @uses bbp_is_favorites()
  * @uses bbp_is_topics_created()
- *
- * @return array
+ * @return array Body Classes
  */
 function bbp_body_class( $wp_classes, $custom_classes = false ) {
 
@@ -477,7 +483,8 @@
 	if ( empty( $url ) && ( !$url = wp_get_referer() ) && ( !empty( $_SERVER['REQUEST_URI'] ) ) )
 		$url = $_SERVER['REQUEST_URI'];
 
-	$url = (string) esc_attr( $url );
+	// Remove loggedout query arg if it's there
+	$url = (string) esc_attr( remove_query_arg( 'loggedout', $url ) );
 
 	$referer_field = '<input type="hidden" name="redirect_to" value="' . $url . '" />';
 
@@ -630,6 +637,8 @@
 	 *                              dropdown
 	 * @uses current_user_can() To check if the current user can read
 	 *                           private forums
+	 * @uses bbp_get_forum_post_type() To get the forum post type
+	 * @uses bbp_get_topic_post_type() To get the topic post type
 	 * @uses walk_page_dropdown_tree() To generate the dropdown using the
 	 *                                  walker
 	 * @uses apply_filters() Calls 'bbp_get_dropdown' with the dropdown
@@ -1008,7 +1017,7 @@
  *
  * @since bbPress (r2692)
  *
- * @uses bbp_set_query_name() To set the query var '_bbp_query_name' to ''
+ * @uses bbp_set_query_name() To set the query var '_bbp_query_name' value to ''
  */
 function bbp_reset_query_name() {
 	bbp_set_query_name();
@@ -1050,6 +1059,9 @@
 	 * @uses bbp_get_topic_permalink() To get the topic link
 	 * @uses bbp_get_reply_permalink() To get the reply link
 	 * @uses get_permalink() To get the permalink
+	 * @uses bbp_get_forum_post_type() To get the forum post type
+	 * @uses bbp_get_topic_post_type() To get the topic post type
+	 * @uses bbp_get_reply_post_type() To get the reply post type
 	 * @uses bbp_get_forum_title() To get the forum title
 	 * @uses bbp_get_topic_title() To get the topic title
 	 * @uses bbp_get_reply_title() To get the reply title
@@ -1141,10 +1153,10 @@
 		return apply_filters( 'bbp_get_allowed_tags', allowed_tags() );
 	}
 
-/** Errors ********************************************************************/
+/** Errors & Messages *********************************************************/
 
 /**
- * Display possible error messages inside a template file
+ * Display possible errors & messages inside a template file
  *
  * @since bbPress (r2688)
  *
@@ -1153,18 +1165,43 @@
  *                                                       messages
  * @uses is_wp_error() To check if it's a {@link WP_Error}
  */
-function bbp_error_messages() {
+function bbp_template_notices() {
 	global $bbp;
 
-	if ( isset( $bbp->errors ) && is_wp_error( $bbp->errors ) && $bbp->errors->get_error_codes() ) : ?>
+	if ( !isset( $bbp->errors ) || !is_wp_error( $bbp->errors ) || !$bbp->errors->get_error_codes() )
+		return;
 
+	$errors = $messages = array();
+
+	foreach ( $bbp->errors->get_error_codes() as $code ) {
+		$severity = $bbp->errors->get_error_data( $code );
+		foreach ( $bbp->errors->get_error_messages( $code ) as $error ) {
+			if ( 'message' == $severity )
+				$messages[] = $error;
+			else
+				$errors[]   = $error;
+		}
+	}
+
+	if ( !empty( $errors ) ) : ?>
+
 		<div class="bbp-template-notice error">
 			<p>
-				<?php echo implode( "</p>\n<p>", $bbp->errors->get_error_messages() ); ?>
+				<?php echo implode( "</p>\n<p>", $errors ); ?>
 			</p>
 		</div>
 
-<?php endif;
+	<?php endif;
+
+	if ( !empty( $messages ) ) : ?>
+
+		<div class="bbp-template-notice">
+			<p>
+				<?php echo implode( "</p>\n<p>", $messages ); ?>
+			</p>
+		</div>
+
+	<?php endif;
 }
 
 /** Login/logout/register/lost pass *******************************************/
@@ -1192,7 +1229,10 @@
 	 * @return string The logout link
 	 */
 	function bbp_get_logout_link( $redirect_to = '' ) {
-		return apply_filters( 'bbp_get_logout_link', '<a href="' . wp_logout_url() . '" class="button logout-link">' . __( 'Log Out', 'bbpress' ) . '</a>', $redirect_to );
+		if ( empty( $redirect_to ) )
+			$redirect_to = add_query_arg( array( 'loggedout' => '1' ) );
+
+		return apply_filters( 'bbp_get_logout_link', '<a href="' . wp_logout_url( $redirect_to ) . '" class="button logout-link">' . __( 'Log Out', 'bbpress' ) . '</a>', $redirect_to );
 	}
 
 ?>
Index: bbp-includes/bbp-hooks.php
===================================================================
--- bbp-includes/bbp-hooks.php	(revision 2961)
+++ bbp-includes/bbp-hooks.php	(working copy)
@@ -75,12 +75,13 @@
 add_action( 'widgets_init', create_function( '', 'return register_widget("BBP_Topics_Widget");'  ) );
 add_action( 'widgets_init', create_function( '', 'return register_widget("BBP_Replies_Widget");' ) );
 
-// Template - Head, foot, errors and notices
-add_action( 'wp_head',              'bbp_head'                  );
-add_filter( 'wp_title',             'bbp_title',          10, 3 );
-add_action( 'wp_footer',            'bbp_footer'                );
-add_action( 'bbp_template_notices', 'bbp_error_messages'        );
-add_action( 'bbp_template_notices', 'bbp_topic_notices'         );
+// Template - Head, foot, errors and messages
+add_action( 'wp_head',              'bbp_head'                    );
+add_filter( 'wp_title',             'bbp_title',            10, 3 );
+add_action( 'wp_footer',            'bbp_footer'                  );
+add_action( 'bbp_loaded',           'bbp_login_notices'           );
+add_action( 'bbp_head',             'bbp_topic_notices'           );
+add_action( 'bbp_template_notices', 'bbp_template_notices'        );
 
 // Add to body class
 add_filter( 'body_class', 'bbp_body_class', 10, 2 );
@@ -299,14 +300,14 @@
 bbp_pre_anonymous_filters();
 
 /**
- * On multiblog installations you must first allow themes to be activated and show
- * up on the theme selection screen. This function will let the bbPress bundled
- * themes show up and bypass this step.
+ * On multiblog installations you must first allow themes to be activated and
+ * show up on the theme selection screen. This function will let the bbPress
+ * bundled themes show up and bypass this step.
  *
  * @since bbPress (r2944)
  *
- * @uses is_super_admin()
- * @uses apply_filters()
+ * @uses is_super_admin() To check if the user is site admin
+ * @uses apply_filters() Calls 'bbp_allowed_themes' with the allowed themes list
  */
 function bbp_allowed_themes( $themes ) {
 	if ( !is_super_admin() )
Index: bbp-includes/bbp-topic-template.php
===================================================================
--- bbp-includes/bbp-topic-template.php	(revision 2961)
+++ bbp-includes/bbp-topic-template.php	(working copy)
@@ -10,26 +10,27 @@
 /** Post Type *****************************************************************/
 
 /**
- * Return the unique ID of the custom post type for topics
+ * Output the unique id of the custom post type for topics
  *
  * @since bbPress (r2857)
  *
- * @global bbPress $bbp
- * @return string
+ * @uses bbp_get_topic_post_type() To get the topic post type
  */
 function bbp_topic_post_type() {
 	echo bbp_get_topic_post_type();
 }
 	/**
-	 * Return the unique ID of the custom post type for topics
+	 * Return the unique id of the custom post type for topics
 	 *
 	 * @since bbPress (r2857)
 	 *
-	 * @global bbPress $bbp
-	 * @return string
+	 * @uses apply_filters() Calls 'bbp_get_topic_post_type' with the topic
+	 *                        post type id
+	 * @return string The unique topic post type id
 	 */
 	function bbp_get_topic_post_type() {
 		global $bbp;
+
 		return apply_filters( 'bbp_get_topic_post_type', $bbp->topic_post_type );
 	}
 
@@ -41,11 +42,12 @@
  * @since bbPress (r2485)
  *
  * @param mixed $args All the arguments supported by {@link WP_Query}
- * @uses bbp_is_user_profile_page() To check if it's the profile page
- * @uses get_the_ID() To get the id
+ * @uses current_user_can() To check if the current user can edit other's topics
+ * @uses bbp_get_topic_post_type() To get the topic post type
  * @uses WP_Query To make query and get the topics
  * @uses is_page() To check if it's a page
  * @uses bbp_is_forum() To check if it's a forum
+ * @uses bbp_get_forum_id() To get the forum id
  * @uses bbp_get_paged() To get the current page value
  * @uses bbp_get_super_stickies() To get the super stickies
  * @uses bbp_get_stickies() To get the forum stickies
@@ -283,8 +285,11 @@
 	 * @uses bbp_is_reply() To check if it it's a reply page
 	 * @uses bbp_is_reply_edit() To check if it's a reply edit page
 	 * @uses bbp_get_reply_topic_edit() To get the reply topic id
+	 * @uses get_post_field() To get the post's post type
 	 * @uses WP_Query::post::ID To get the topic id
-	 * @uses apply_filters() Calls 'bbp_get_topic_id' with the topic id
+	 * @uses apply_filters() Calls 'bbp_get_topic_id' with the topic id and
+	 *                        supplied topic id
+	 * @return int The topic id
 	 */
 	function bbp_get_topic_id( $topic_id = 0 ) {
 		global $bbp, $wp_query, $bbp;
@@ -529,7 +534,7 @@
 	 * @uses bbp_get_topic_revisions() To get the topic revisions
 	 * @uses bbp_get_topic_raw_revision_log() To get the raw revision log
 	 * @uses bbp_get_topic_author_display_name() To get the topic author
-	 * @uses bbp_get_topic_author_link() To get the topic author link
+	 * @uses bbp_get_author_link() To get the topic author link
 	 * @uses bbp_convert_date() To convert the date
 	 * @uses bbp_get_time_since() To get the time in since format
 	 * @uses apply_filters() Calls 'bbp_get_topic_revision_log' with the
@@ -758,7 +763,7 @@
  * @param int $topic_id Optional. Topic id
  * @uses bbp_get_topic_id() To get the topic id
  * @uses bbp_get_topic_status() To get the topic status
- * @return bool True if spam, false if not.
+ * @return bool True if trashed, false if not.
  */
 function bbp_is_topic_trash( $topic_id = 0 ) {
 	global $bbp;
@@ -814,6 +819,9 @@
 	 * @uses bbp_get_topic_id() To get the topic id
 	 * @uses bbp_is_topic_anonymous() To check if the topic is by an
 	 *                                 anonymous user
+	 * @uses bbp_get_topic_author_id() To get the topic author id
+	 * @uses get_the_author_meta() To get the display name of the author
+	 * @uses get_post_meta() To get the name of the anonymous poster
 	 * @uses apply_filters() Calls 'bbp_get_topic_author' with the author
 	 *                        and topic id
 	 * @return string Author of topic
@@ -1116,9 +1124,11 @@
 	 *
 	 * @param int $topic_id Optional. Topic id
 	 * @uses bbp_get_topic_id() To get topic id
-	 * @uses get_post_field() To get get topic's parent
+	 * @uses get_post_meta() To retrieve get topic's forum id meta
+	 * @uses get_post_field() To get the topic's parent, i.e. forum id
+	 * @uses bbp_update_topic_forum_id() To update the topic forum id
 	 * @uses apply_filters() Calls 'bbp_get_topic_forum_id' with the forum
-	 *  id and topic id
+	 *                        id and topic id
 	 * @return int Topic forum id
 	 */
 	function bbp_get_topic_forum_id( $topic_id = 0 ) {
@@ -1139,8 +1149,8 @@
  *
  * @since bbPress (r2860)
  *
+ * @param int $topic_id Optional. Forum id
  * @uses bbp_get_topic_last_active_id() To get the topic's last active id
- * @param int $topic_id Optional. Forum id
  */
 function bbp_topic_last_active_id( $topic_id = 0 ) {
 	echo bbp_get_topic_last_active_id( $topic_id );
@@ -1483,7 +1493,7 @@
 	 * @uses get_post_meta() To get the topic post count meta
 	 * @uses apply_filters() Calls 'bbp_get_topic_post_count' with the
 	 *                        post count and topic id
-	 * @return int post count
+	 * @return int Post count
 	 */
 	function bbp_get_topic_post_count( $topic_id = 0 ) {
 		$topic_id = bbp_get_topic_id( $topic_id );
@@ -1846,6 +1856,7 @@
 	 * @uses bbp_get_topic() To get the topic
 	 * @uses current_user_can() To check if the current user can delete the
 	 *                           topic
+	 * @uses bbp_is_topic_trash() To check if the topic is trashed
 	 * @uses bbp_get_topic_status() To get the topic status
 	 * @uses add_query_arg() To add custom args to the url
 	 * @uses wp_nonce_url() To nonce the url
@@ -2219,6 +2230,10 @@
  *
  * @uses bbp_is_topic() To check if it's a topic page
  * @uses bbp_get_topic_status() To get the topic status
+ * @uses bbp_get_topic_id() To get the topic id
+ * @uses apply_filters() Calls 'bbp_topic_notices' with the notice text, topic
+ *                        status and topic id
+ * @uses bbPress::errors::add() To add the notices to the error handler
  */
 function bbp_topic_notices() {
 	global $bbp;
@@ -2250,14 +2265,10 @@
 	}
 
 	// Filter notice text and bail if empty
-	if ( ! $notice_text = apply_filters( 'bbp_topic_notices', $notice_text, $topic_status, bbp_get_topic_id() ) )
-		return; ?>
+	if ( !$notice_text = apply_filters( 'bbp_topic_notices', $notice_text, $topic_status, bbp_get_topic_id() ) )
+		return;
 
-	<div class="bbp-template-notice error">
-		<p><?php echo $notice_text; ?></p>
-	</div>
-
-	<?php
+	$bbp->errors->add( 'topic_notice', $notice_text, 'message' );
 }
 
 /**
@@ -2335,9 +2346,8 @@
  *
  * @since bbPress (r2860)
  *
+ * @param array $args See {@link bbp_get_single_topic_description()}
  * @uses bbp_get_single_topic_description() Return the eventual output
- *
- * @param arr $args Arguments passed to alter output
  */
 function bbp_single_topic_description( $args = '' ) {
 	echo bbp_get_single_topic_description( $args );
@@ -2348,19 +2358,19 @@
 	 *
 	 * @since bbPress (r2860)
 	 *
-	 * @uses wp_parse_args()
-	 * @uses bbp_get_topic_id()
-	 * @uses bbp_get_topic_topic_count()
-	 * @uses bbp_get_topic_reply_count()
-	 * @uses bbp_get_topic_subtopic_count()
-	 * @uses bbp_get_topic_freshness_link()
-	 * @uses bbp_get_topic_last_reply_id()
-	 * @uses bbp_get_reply_author_avatar()
-	 * @uses bbp_get_reply_author_link()
-	 * @uses apply_filters()
-	 *
-	 * @param arr $args Arguments passed to alter output
-	 *
+	 * @param mixed $args This function supports these arguments:
+	 *  - topic_id: Topic id
+	 *  - before: Before the text
+	 *  - after: After the text
+	 *  - size: Size of the avatar
+	 * @uses bbp_get_topic_id() To get the topic id
+	 * @uses bbp_get_topic_voice_count() To get the topic voice count
+	 * @uses bbp_get_topic_reply_count() To get the topic reply count
+	 * @uses bbp_get_topic_freshness_link() To get the topic freshness link
+	 * @uses bbp_get_topic_last_active_id() To get the topic last active id
+	 * @uses bbp_get_reply_author_link() To get the reply author link
+	 * @uses apply_filters() Calls 'bbp_get_single_topic_description' with
+	 *                        the description and args
 	 * @return string Filtered topic description
 	 */
 	function bbp_get_single_topic_description( $args = '' ) {
Index: bbp-includes/bbp-user-template.php
===================================================================
--- bbp-includes/bbp-user-template.php	(revision 2961)
+++ bbp-includes/bbp-user-template.php	(working copy)
@@ -537,8 +537,8 @@
 	 *
 	 * @param int $user_id Optional. User id
 	 * @uses bbp_get_user_profile_url() To get the user profile url
-	 * @uses apply_filters() Calls 'bbp_get_favorites_permalink' with the
-	 *                        user profile url and user id
+	 * @uses apply_filters() Calls 'bbp_get_subscriptions_permalink' with
+	 *                        the user profile url and user id
 	 * @return string Permanent link to user subscriptions page
 	 */
 	function bbp_get_subscriptions_permalink( $user_id = 0 ) {
@@ -763,6 +763,28 @@
 
 /** Login *********************************************************************/
 
+function bbp_login_notices() {
+	global $bbp;
+
+	if ( !empty( $_GET['loggedout'] ) && true == $_GET['loggedout'] ) {
+		$bbp->errors->add( 'loggedout', __( 'You are now logged out.', 'bbpress' ), 'message' );
+	} elseif ( !empty( $_GET['registration'] ) && 'disabled' == $_GET['registration'] ) {
+		$bbp->errors->add( 'registerdisabled', __( 'User registration is currently not allowed.', 'bbpress' ) );
+	} elseif ( !empty( $_GET['checkemail'] ) && in_array( $_GET['checkemail'], array( 'confirm', 'newpass', 'registered' ) ) ) {
+		switch ( $_GET['checkemail'] ) {
+			case 'confirm' :
+				$bbp->errors->add( 'confirm',    __( 'Check your e-mail for the confirmation link.',     'bbpress' ), 'message' );
+				break;
+			case 'newpass' :
+				$bbp->errors->add( 'newpass',    __( 'Check your e-mail for your new password.',         'bbpress' ), 'message' );
+				break;
+			case 'registered' :
+				$bbp->errors->add( 'registered', __( 'Registration complete. Please check your e-mail.', 'bbpress' ), 'message' );
+				break;
+		}
+	}
+}
+
 /**
  * Redirect a user back to their profile if they are already logged in.
  *
@@ -812,14 +834,18 @@
  *
  * @since bbPress (r2815)
  *
+ * @uses bbp_login_url() To get the login url
+ * @uses bbp_redirect_to_field() To output the redirect to field
  * @uses wp_nonce_field() To generate hidden nonce fields
  */
 function bbp_user_register_fields() {
 ?>
 
-		<input type="hidden" name="action"      value="bbp-user-register" id="bbp_user_register" />
+		<input type="hidden" name="action"      value="register" />
 		<input type="hidden" name="user-cookie" value="1" />
 
+		<?php bbp_redirect_to_field( add_query_arg( array( 'checkemail' => 'registered' ), bbp_login_url() ) ); ?>
+
 		<?php wp_nonce_field( 'bbp-user-register' );
 }
 
@@ -861,14 +887,16 @@
 	 * @since bbPress (r2875)
 	 *
 	 * @param mixed $args Optional. If an integer, it is used as reply id.
-	 * @uses bbp_get_reply_id() To get the reply id
 	 * @uses bbp_is_topic() To check if it's a topic page
+	 * @uses bbp_get_topic_author_link() To get the topic author link
 	 * @uses bbp_is_reply() To check if it's a reply page
+	 * @uses bbp_get_reply_author_link() To get the reply author link
+	 * @uses get_post_field() To get the post author
 	 * @uses bbp_is_reply_anonymous() To check if the reply is by an
 	 *                                 anonymous user
-	 * @uses bbp_get_reply_author() To get the reply author name
-	 * @uses bbp_get_reply_author_url() To get the reply author url
-	 * @uses bbp_get_reply_author_avatar() To get the reply author avatar
+	 * @uses get_the_author_meta() To get the author name
+	 * @uses bbp_get_user_profile_url() To get the author profile url
+	 * @uses get_avatar() To get the author avatar
 	 * @uses apply_filters() Calls 'bbp_get_reply_author_link' with the
 	 *                        author link and args
 	 * @return string Author link of reply
Index: bbp-includes/bbp-widgets.php
===================================================================
--- bbp-includes/bbp-widgets.php	(revision 2961)
+++ bbp-includes/bbp-widgets.php	(working copy)
@@ -65,8 +65,6 @@
 				<fieldset>
 					<legend><?php _e( 'Login', 'bbpress' ); ?></legend>
 
-					<?php do_action( 'bbp_template_notices' ); ?>
-
 					<div class="bbp-username">
 						<label for="user_login"><?php _e( 'Username', 'bbpress' ); ?>: </label>
 						<input type="text" name="log" value="<?php bbp_sanitize_val( 'user_login', 'text' ); ?>" size="20" id="user_login" tabindex="<?php bbp_tab_index(); ?>" />
@@ -182,6 +180,11 @@
 	 * @param mixed $args Arguments
 	 * @param array $instance Instance
 	 * @uses apply_filters() Calls 'bbp_forum_widget_title' with the title
+	 * @uses get_option() To get the forums per page option
+	 * @uses current_user_can() To check if the current user can read
+	 *                           private() To resety name
+	 * @uses bbp_set_query_name() To set the query name to 'bbp_widget'
+	 * @uses bbp_reset_query_name() To reset the query name
 	 * @uses bbp_has_forums() The main forum loop
 	 * @uses bbp_forums() To check whether there are more forums available
 	 *                     in the loop
@@ -314,13 +317,16 @@
 	 * @param mixed $args
 	 * @param array $instance
 	 * @uses apply_filters() Calls 'bbp_topic_widget_title' with the title
+	 * @uses bbp_set_query_name() To set the query name to 'bbp_widget'
+	 * @uses bbp_reset_query_name() To reset the query name
 	 * @uses bbp_has_topics() The main topic loop
 	 * @uses bbp_topics() To check whether there are more topics available
 	 *                     in the loop
 	 * @uses bbp_the_topic() Loads up the current topic in the loop
 	 * @uses bbp_topic_permalink() To display the topic permalink
 	 * @uses bbp_topic_title() To display the topic title
-	 * @uses bbp_get_topic_last_active_time() To get the topic last active time
+	 * @uses bbp_get_topic_last_active_time() To get the topic last active
+	 *                                         time
 	 * @uses bbp_get_topic_id() To get the topic id
 	 * @uses bbp_get_topic_reply_count() To get the topic reply count
 	 */
Index: bbp-themes/bbp-twentyten/bbpress/form-user-login.php
===================================================================
--- bbp-themes/bbp-twentyten/bbpress/form-user-login.php	(revision 2961)
+++ bbp-themes/bbp-twentyten/bbpress/form-user-login.php	(working copy)
@@ -13,8 +13,6 @@
 		<fieldset>
 			<legend><?php _e( 'Login', 'bbpress' ); ?></legend>
 
-			<?php do_action( 'bbp_template_notices' ); ?>
-
 			<div class="bbp-username">
 				<label for="user_login"><?php _e( 'Username', 'bbpress' ); ?>: </label>
 				<input type="text" name="log" value="<?php bbp_sanitize_val( 'user_login', 'text' ); ?>" size="20" id="user_login" tabindex="<?php bbp_tab_index(); ?>" />
Index: bbp-themes/bbp-twentyten/bbpress/form-user-register.php
===================================================================
--- bbp-themes/bbp-twentyten/bbpress/form-user-register.php	(revision 2961)
+++ bbp-themes/bbp-twentyten/bbpress/form-user-register.php	(working copy)
@@ -9,12 +9,10 @@
 
 ?>
 
-	<form method="post" action="<?php bbp_wp_login_action( array( 'action' => 'register', 'context' => 'login_post' ) ); ?>" class="bbp-login-form">
+	<form method="post" action="<?php bbp_wp_login_action( array( 'context' => 'login_post' ) ); ?>" class="bbp-login-form">
 		<fieldset>
 			<legend><?php _e( 'Register', 'bbpress' ); ?></legend>
 
-			<?php do_action( 'bbp_template_notices' ); ?>
-
 			<div class="bbp-username">
 				<label for="user_login"><?php _e( 'Username', 'bbpress' ); ?>: </label>
 				<input type="text" name="user_login" value="<?php bbp_sanitize_val( 'user_login' ); ?>" size="20" id="user_login" tabindex="<?php bbp_tab_index(); ?>" />
@@ -25,10 +23,12 @@
 				<input type="text" name="user_email" value="<?php bbp_sanitize_val( 'user_email' ); ?>" size="20" id="user_email" tabindex="<?php bbp_tab_index(); ?>" />
 			</div>
 
+			<?php do_action( 'register_form' ); ?>
+
+			<p id="reg_passmail"><?php _e( 'A password will be e-mailed to you.', 'bbpress' ) ?></p>
+
 			<div class="bbp-submit-wrapper">
 
-				<?php do_action( 'register_form' ); ?>
-
 				<button type="submit" name="user-submit" tabindex="<?php bbp_tab_index(); ?>" class="user-submit"><?php _e( 'Register', 'bbpress' ); ?></button>
 
 				<?php bbp_user_register_fields(); ?>
