diff --git a/masquerade.module b/masquerade.module
index a487b60..1d004b2 100644
--- a/masquerade.module
+++ b/masquerade.module
@@ -175,9 +175,11 @@ function masquerade_translated_menu_link_alter(&$item, $map) {
   if (isset($item['page_callback'])) {
     if ($item['page_callback'] == 'masquerade_switch_user_page' && isset($map[2])) {
       $item['localized_options']['query']['token'] = drupal_get_token('masquerade/switch/' . $map[2]);
+      $item['localized_options']['query'] += drupal_get_destination();
     }
     elseif ($item['page_callback'] == 'masquerade_switch_back_page') {
       $item['localized_options']['query']['token'] = drupal_get_token('masquerade/unswitch');
+      $item['localized_options']['query'] += drupal_get_destination();
     }
   }
 }
@@ -549,7 +551,9 @@ function masquerade_block_1() {
   $quick_switch_links = array();
   $markup_value = '';
   if (isset($_SESSION['masquerading'])) {
-    $quick_switch_links[] = l(t('Switch back'), 'masquerade/unswitch', array('query' => array('token' => drupal_get_token('masquerade/unswitch'))));
+    $quick_switch_links[] = l(t('Switch back'), 'masquerade/unswitch', array(
+      'query' => array('token' => drupal_get_token('masquerade/unswitch')) + drupal_get_destination(),
+    ));
     if ($user->uid > 0) {
       $markup_value = t('You are masquerading as <a href="@user-url">%masq_as</a>.', array('@user-url' => url('user/' . $user->uid), '%masq_as' => $user->name));
     }
@@ -570,7 +574,9 @@ function masquerade_block_1() {
         if (isset($account->uid)) {
           $switch_link = 'masquerade/switch/' . $account->uid;
           if ($account->uid) {
-            $quick_switch_links[] = l($account->name, $switch_link, array('query' => array('token' => drupal_get_token($switch_link))));
+            $quick_switch_links[] = l($account->name, $switch_link, array(
+              'query' => array('token' => drupal_get_token($switch_link)) + drupal_get_destination(),
+            ));
           }
           if ($switch_user == 0) {
             $account->name = variable_get('anonymous', t('Anonymous'));
@@ -651,9 +657,6 @@ function masquerade_block_1_submit($form, &$form_state) {
   if (!masquerade_switch_user($masq_user->uid)) {
     drupal_access_denied();
   }
-  else {
-    drupal_goto($_SERVER['HTTP_REFERER']);
-  }
 }
 
 /**
@@ -736,6 +739,9 @@ function masquerade_autocomplete_multiple($string, $add_anonymous = TRUE) {
  */
 function masquerade_switch_user_page($uid) {
   if (isset($_GET['token']) && drupal_valid_token($_GET['token'], 'masquerade/switch/' . $uid) && masquerade_switch_user($uid)) {
+    if (isset($_GET['destination'])) {
+      drupal_goto($_GET['destination']);
+    }
     drupal_goto($_SERVER['HTTP_REFERER']);
   }
   else {
@@ -821,6 +827,9 @@ function masquerade_switch_back_page() {
     $olduser = $user;
     masquerade_switch_back();
     drupal_set_message(t('You are no longer masquerading as !masq_as and are now logged in as !user.', array('!user' => theme('username', array('account' => $user)), '!masq_as' => theme('username', array('account' => $olduser)))));
+    if (isset($_GET['destination'])) {
+      drupal_goto($_GET['destination']);
+    }
     drupal_goto($_SERVER['HTTP_REFERER']);
   }
   else {
