diff --git a/bakery.module b/bakery.module
index 18c2bf2..465f19f 100644
--- a/bakery.module
+++ b/bakery.module
@@ -100,7 +100,8 @@ function bakery_perm() {
 function bakery_user($op, &$array, &$account, $category = NULL) {
   if ($op == 'login') {
     if (variable_get('bakery_is_master', 0)) {
-      _bakery_bake_chocolatechip_cookie($account->name, $account->mail, url("user/$account->uid/edit", array('absolute' => TRUE)));
+      $init = _bakery_init_field($account->uid);
+      _bakery_bake_chocolatechip_cookie($account->name, $account->mail, $init);
     }
   }
   else if ($op == 'logout') {
@@ -170,11 +171,13 @@ function bakery_user($op, &$array, &$account, $category = NULL) {
     }
   }
   else if ($op == 'view' && !variable_get('bakery_is_master', 0)) {
-    if (substr($account->init, 0, strlen(variable_get('bakery_master', 'http://drupal.org/'))) == variable_get('bakery_master', 'http://drupal.org/')) {
+    $master = variable_get('bakery_master', 'http://drupal.org/');
+    $init_url = _bakery_init_field_url($account->init);
+    if (parse_url($master, PHP_URL_HOST) == parse_url($init_url, PHP_URL_HOST)) {
       $account->content['summary']['master_profile'] = array(
         '#type' => 'item',
         '#title' => t('Primary profile'),
-        '#value' => l(t('Profile on @master', array('@master' => variable_get('bakery_master', 'http://drupal.org'))), substr($account->init, 0, strlen($account->init) - 5)), // Remove the /edit part of the url.
+        '#value' => l(t('Profile on @master', array('@master' => variable_get('bakery_master', 'http://drupal.org'))), substr($init_url, 0, strlen($init_url) - 5)), // Remove the /edit part of the url.
         '#attributes' => array('class' => 'og_groups'),
         '#access' => user_access('access user profiles'),
       );
@@ -199,9 +202,10 @@ function bakery_form_alter(&$form, $form_state, $form_id) {
     case 'user_profile_form':
     case 'user_edit_form':
       if (!variable_get('bakery_is_master', 0) && !user_access('administer users')) {
+        $init_url = _bakery_init_field_url($form['_account']['#value']->init);
         $index = key($form);
         if (isset($form['account'])) {
-          drupal_set_message(t('You can change the name, mail, and password at <a href="!url">@master</a>.', array('!url' => check_url($form['_account']['#value']->init), '@master' => variable_get('bakery_master', 'http://drupal.org'))), 'status', FALSE);
+          drupal_set_message(t('You can change the name, mail, and password at <a href="!url">@master</a>.', array('!url' => check_url($init_url), '@master' => variable_get('bakery_master', 'http://drupal.org'))), 'status', FALSE);
           $form['account']['#access'] = FALSE;
           $form['account']['name']['#access'] = FALSE;
           $form['account']['pass']['#access'] = FALSE;
@@ -217,19 +221,19 @@ function bakery_form_alter(&$form, $form_state, $form_id) {
                 if (isset($form['picture'])) {
                   $form['picture']['picture_delete']['#access'] = FALSE;
                   $form['picture']['picture_upload']['#access'] = FALSE;
-                  $form['picture']['#description'] .= ' '. t('You can change the image at <a href="!url">@master</a>.', array('!url' => check_url($form['_account']['#value']->init)));
+                  $form['picture']['#description'] .= ' '. t('You can change the image at <a href="!url">@master</a>.', array('!url' => check_url($init_url)));
                 }
                 break;
               case 'language':
                 if (isset($form['locale'][$type])) {
                   $form['locale'][$type]['#disabled'] = TRUE;
-                  $form['locale'][$type]['#description'] .= ' '. t('You can change the language setting at <a href="!url">@master</a>.', array('!url' => check_url($form['_account']['#value']->init), '@master' => variable_get('bakery_master', 'http://drupal.org')));
+                  $form['locale'][$type]['#description'] .= ' '. t('You can change the language setting at <a href="!url">@master</a>.', array('!url' => check_url($init_url), '@master' => variable_get('bakery_master', 'http://drupal.org')));
                 }
                 break;
               case 'signature':
                 if (isset($form['signature_settings'][$type])) {
                   $form['signature_settings'][$type]['#disabled'] = TRUE;
-                  $form['signature_settings'][$type]['#description'] .= ' '. t('You can change the signature at <a href="!url">@master</a>.', array('!url' => check_url($form['_account']['#value']->init), '@master' => variable_get('bakery_master', 'http://drupal.org')));
+                  $form['signature_settings'][$type]['#description'] .= ' '. t('You can change the signature at <a href="!url">@master</a>.', array('!url' => check_url($init_url), '@master' => variable_get('bakery_master', 'http://drupal.org')));
                 }
                 break;
               default:
@@ -238,12 +242,12 @@ function bakery_form_alter(&$form, $form_state, $form_id) {
                 }
                 if (isset($form[$type][$type])) {
                   $form[$type][$type]['#disabled'] = TRUE;
-                  $form[$type][$type]['#description'] .= ' '. t('You can change this setting at <a href="!url">@master</a>.', array('!url' => check_url($form['_account']['#value']->init), '@master' => variable_get('bakery_master', 'http://drupal.org')));
+                  $form[$type][$type]['#description'] .= ' '. t('You can change this setting at <a href="!url">@master</a>.', array('!url' => check_url($init_url), '@master' => variable_get('bakery_master', 'http://drupal.org')));
                 }
                 // profile fields
                 if ($form[$index]['#type'] == 'fieldset' && isset($form[$index][$type])) {
                   $form[$index][$type]['#disabled'] = TRUE;
-                  $form[$index][$type]['#description'] .= ' '. t('You can change this setting at <a href="!url">@master</a>.', array('!url' => check_url($form['_account']['#value']->init), '@master' => variable_get('bakery_master', 'http://drupal.org')));
+                  $form[$index][$type]['#description'] .= ' '. t('You can change this setting at <a href="!url">@master</a>.', array('!url' => check_url($init_url), '@master' => variable_get('bakery_master', 'http://drupal.org')));
                 }
                 break;
             }
@@ -370,7 +374,7 @@ function _bakery_reset_submit($form, &$form_state) {
     $edit = array('name' => $user->name);
     bakery_user_authenticate_finalize($edit);
     // Inform them that they need to reset their password.
-    drupal_set_message(t('You have just used your one-time login link. It is no longer necessary to use this link to login. Please change your password at <a href="!url">@master</a>.', array('!url' => check_url($user->init), '@master' => variable_get('bakery_master', ''))));
+    drupal_set_message(t('You have just used your one-time login link. It is no longer necessary to use this link to login. Please change your password at <a href="!url">@master</a>.', array('!url' => check_url(_bakery_init_field_url($user->init)), '@master' => variable_get('bakery_master', ''))));
     drupal_goto('user/'. $user->uid);
   }
   else {
@@ -679,7 +683,7 @@ function bakery_register_return() {
         $new = array(
             'name' => $cookie['name'],
             'mail' => $cookie['data']['mail'],
-            'init' => variable_get('bakery_master', '') . 'user/' . $cookie['data']['uid'] . '/edit',
+            'init' => _bakery_init_field($cookie['data']['uid']),
             'status' => 1,
             'pass' => user_password(),
           );
@@ -1100,7 +1104,7 @@ function bakery_eat_stroopwafel_cookie() {
   $stroopwafel = $_SESSION['bakery'];
   unset($_SESSION['bakery']);
 
-  $init = variable_get('bakery_master', 'http://drupal.org/') .'user/'. $stroopwafel['uid'] .'/edit';
+  $init = _bakery_init_field($stroopwafel['uid']);
 
   // check if the user exists.
   $account = user_load(array('init' => $init));
@@ -1297,7 +1301,7 @@ function bakery_request_account($name, $or_email = FALSE) {
   // Fill in details from master and create account.
   $account = user_save($account, array_merge(bakery_prepare_fields($cookie, $account), array(
     'pass' => user_password(),
-    'init' => $master . 'user/' . $cookie['uid'] . '/edit',
+    'init' => _bakery_init_field($cookie['uid']),
   )));
   if ($account) {
     watchdog('bakery', 'Created account for @name', array('@name' => $name));
@@ -1393,6 +1397,23 @@ function _bakery_eat_cookie($type = 'CHOCOLATECHIP') {
 }
 
 /**
+ * Build internal init url (without scheme).
+ */
+function _bakery_init_field($uid) {
+  $url = variable_get('bakery_master', 'http://drupal.org/');
+  $scheme = parse_url($url, PHP_URL_SCHEME);
+  return str_replace($scheme . '://', '', $url) . 'user/' . $uid . '/edit';
+}
+
+/**
+ * Build full init url to master.
+ */
+function _bakery_init_field_url($init) {
+  $scheme = parse_url(variable_get('bakery_master', 'http://drupal.org/'), PHP_URL_SCHEME);
+  return $scheme . '://'. $init;
+}
+
+/**
  * Encryption
  *
  * @param $text, The text that you want to encrypt.
@@ -1697,4 +1718,4 @@ function bakery_pull_form_submit($form, &$form_state) {
   else {
     $form_state['redirect'] = 'user/' . $result;
   }
-}
+}
\ No newline at end of file
