diff --git a/fboauth.module b/fboauth.module
index 0b49720..0ef4138 100644
--- a/fboauth.module
+++ b/fboauth.module
@@ -77,7 +77,9 @@
 function fboauth_block_view($delta) {
   $block = array();
   if (variable_get('fboauth_id', '') && !fboauth_fbid_load()) {
-    $block['content'] = fboauth_action_display('connect');
+    // Set the redirect to the current page (unless we're on the login page).
+    $redirect = (arg(0) === 'user' && (arg(1) === 'login' || arg(1) == '')) ? NULL : $_GET['q'];
+    $block['content'] = fboauth_action_display('connect', $redirect);
   }
   return $block;
 }
@@ -338,6 +340,11 @@
     $query['destination'] = $_GET['destination'];
   }
 
+  // Remove the destination path if it's pointing to the front page.
+  if (isset($query['destination']) && $query['destination'] === variable_get('site_frontpage', 'node')) {
+    unset($query['destination']);
+  }
+
   $return = array(
     'query' => array(
       'client_id' => $app_id,
@@ -428,10 +435,10 @@
   $uid = $variables['uid'];
   $fbid = $variables['fbid'];
   if ($fbid) {
-    $output = t('Your account is connected with Facebook. (<a href="!url">More info</a>)', array('!url' => url('user/' . $uid . '/fboauth')));
+    $output = t('Your account is connected with Facebook. (<a href="!url">More info</a>)', array('!url' => url('user/' . $uid . '/fboauth', array('query' => drupal_get_destination()))));
   }
   else {
-    $output = fboauth_action_display('connect');
+    $output = fboauth_action_display('connect', $_GET['q']);
     $output .= '<div class="description">' . t('Connect with Facebook to login with your Facebook account instead of a password.') . '</div>';
   }
   return $output;