Index: fb.admin.inc
===================================================================
--- fb.admin.inc	(revision 4004)
+++ fb.admin.inc	(working copy)
@@ -365,6 +365,25 @@
     '#description' => t('When fb.js reloads (on session change), append a query parameter which serves two purposes.  First, it will break through a cache which may be desireable when facebook session changes.  Second, it prevents infinite reloads when third-party cookies are not enabled.  Enable this if you encounter either of those problems.'),
   );
 
+  $form['fb_username_performance'] = array(
+    '#title' => t('Username Formatting'),
+    '#type' => 'fieldset',
+    '#description' => t('If some pages render very slowly, you may wish to disable username formatting.'),
+    '#collapsible' => TRUE,
+  );
+  $form['fb_username_performance'][FB_VAR_ALTER_USERNAME] = array(
+    '#type' => 'radios',
+    '#title' => t('Format Usernames'),
+    '#default_value' => variable_get(FB_VAR_ALTER_USERNAME, FB_ALTER_USERNAME_NOT_THEMING),
+    '#description' => t(''),
+    '#options' => array(
+      FB_ALTER_USERNAME_NEVER => t('<strong>Never</strong> - In emails and page titles users might see unsightly names like "12345@facebook".'),
+      FB_ALTER_USERNAME_NOT_THEMING => t('<strong>Smart</strong> - Format names in email and page title, but skip formatting when theming markup.  Recommended; however, due to limitations of Drupal API, this only works when <a href=!url target=_blank>fb_connect.module overrides theme_username()</a>.', array('!url' => url('admin/structure/fb/fb_connect'))),
+      FB_ALTER_USERNAME_ALWAYS => t('<strong>Always</strong> (not recommended) - May cause pages to render slowly.'),
+    ),
+  );
+
+
   $form['fb_admin_languages'] = array(
     '#title' => t('Languages and Locales'),
     '#type' => 'fieldset',
Index: fb.theme.inc
===================================================================
--- fb.theme.inc	(revision 4004)
+++ fb.theme.inc	(working copy)
@@ -39,6 +39,9 @@
 
 
 function theme_fb_username($params) {
+  $is_theming_username = &drupal_static('fb_theming_username');
+  $is_theming_username = TRUE;
+
   $fbu = $params['fbu'];
   $object = $params['account'];
   $orig = $params['orig'];
@@ -58,6 +61,7 @@
 
   $fbml = "<fb:name linked=false useyou=false uid=\"$fbu\" $ifcantsee></fb:name>";  $output =  $wrap_pre . $fbml . $wrap_post;
 
+  $is_theming_username = FALSE;
   return $output;
 }
 
Index: fb.module
===================================================================
--- fb.module	(revision 4006)
+++ fb.module	(working copy)
@@ -53,12 +53,18 @@
 define('FB_VAR_RELOAD_APPEND_HASH', 'fb_reload_append_hash');
 define('FB_VAR_CURL_NOVERIFY', 'fb_curl_noverify');
 define('FB_VAR_SECURE_URLS', 'fb_secure_urls');
+define('FB_VAR_ALTER_USERNAME', 'fb_format_username');
 
 // Possible choices for secure urls.
 define('FB_SECURE_URLS_ALWAYS', 1);
 define('FB_SECURE_URLS_SOMETIMES', 0);
 define('FB_SECURE_URLS_NEVER', -1);
 
+// Possible choices for formatting username.
+define('FB_ALTER_USERNAME_ALWAYS', 'always');
+define('FB_ALTER_USERNAME_NEVER', 'never');
+define('FB_ALTER_USERNAME_NOT_THEMING', 'when_not_theming');
+
 // node_access realms (belongs here?)
 define('FB_GRANT_REALM_FRIEND', 'fb_friend');
 define('FB_GRANT_REALM_GROUP', 'fb_group');
@@ -1538,15 +1544,23 @@
  * @TODO cache, because drupal doesn't, and calls this often.
  */
 function fb_username_alter(&$name, $account) {
-  //dpm(func_get_args(), __FUNCTION__);
   // This function can be called very early in the bootstrap process, before
   // the modules are initialized, in which case we will fail to alter the
   // name.
 
+  $is_theming_username = &drupal_static('fb_theming_username');
+  $enabled = variable_get(FB_VAR_ALTER_USERNAME, FB_ALTER_USERNAME_NOT_THEMING);
+  if ($enabled == FB_ALTER_USERNAME_NEVER ||
+      $enabled == FB_ALTER_USERNAME_NOT_THEMING && $is_theming_username) {
+    // Disable formatting when configured to do so.
+    return;
+  }
+
   // Skip on admin pages.
   if (arg(0) == 'admin') {
     return;
   }
+  dpm(func_get_args(), __FUNCTION__);
 
   if (isset($GLOBALS['_fb']) && $fbu = fb_get_fbu($account)) { // @TODO - is fb_get_fbu() a performance hit here?
     try {
Index: fb_connect.module
===================================================================
--- fb_connect.module	(revision 4004)
+++ fb_connect.module	(working copy)
@@ -438,20 +438,27 @@
  * Our replacement for theme('username', ...)
  */
 function fb_connect_theme_username_override($variables) {
+  // Static helps avoid altering username.  See fb_username_alter.
+  $is_theming_username = &drupal_static('fb_theming_username');
+  $is_theming_username = TRUE;
+
   $account = $variables['account'];
   $orig = theme('fb_connect_username_orig', $variables);
 
   if ($fbu = fb_get_object_fbu($account)) {
     // Theme the username with XFBML, using original username as backup.
-    return theme('fb_username', array(
-        'fbu' => $fbu,
-        'account' => $account,
-        'orig' =>  $orig,
-        ));
+    $return_me = theme('fb_username', array(
+                         'fbu' => $fbu,
+                         'account' => $account,
+                         'orig' =>  $orig,
+                       ));
   }
   else {
-    return $orig;
+    $return_me = $orig;
   }
+
+  $is_theming_username = FALSE;
+  return $return_me;
 }
 
 
