diff --git a/js/gdm/loginDialog.js b/js/gdm/loginDialog.js
index e66789d..fda9a7d 100644
--- a/js/gdm/loginDialog.js
+++ b/js/gdm/loginDialog.js
@@ -472,6 +472,11 @@ const LoginDialog = new Lang.Class({
 
         this._disableUserList = undefined;
         this._userListLoaded = false;
+        this._nextSignalId = 0;
+                
+        this._realmManager = new Realmd.Manager();
+        this._realmSignalId = this._realmManager.connect('login-format-changed',
+                                             Lang.bind(this, this._showRealmLoginHint));
 
         LoginManager.getLoginManager().getCurrentSessionProxy(Lang.bind(this, this._gotGreeterSessionProxy));
 
@@ -620,14 +625,14 @@ const LoginDialog = new Lang.Class({
         this._authPrompt.setPasswordChar('');
         this._authPrompt.setQuestion(_("Username: "));
 
-        let realmManager = new Realmd.Manager();
-        let realmSignalId = realmManager.connect('login-format-changed',
-                                                 Lang.bind(this, this._showRealmLoginHint));
-        this._showRealmLoginHint(realmManager.loginFormat);
+        this._showRealmLoginHint(this._realmManager.loginFormat);
 
-        let nextSignalId = this._authPrompt.connect('next',
+        if (this._nextSignalId)
+                this._authPrompt.disconnect(this._nextSignalId);
+        this._nextSignalId = this._authPrompt.connect('next',
                                                     Lang.bind(this, function() {
-                                                        this._authPrompt.disconnect(nextSignalId);
+                                                        this._authPrompt.disconnect(this._nextSignalId);
+                                                        this._nextSignalId = 0;
                                                         this._authPrompt.updateSensitivity(false);
                                                         let answer = this._authPrompt.getAnswer();
                                                         this._user = this._userManager.get_user(answer);
@@ -635,9 +640,6 @@ const LoginDialog = new Lang.Class({
                                                         this._authPrompt.startSpinning();
                                                         this._authPrompt.begin({ userName: answer });
                                                         this._updateCancelButton();
-
-                                                        realmManager.disconnect(realmSignalId)
-                                                        realmManager.release();
                                                     }));
         this._updateCancelButton();
         this._showPrompt();
@@ -892,6 +894,11 @@ const LoginDialog = new Lang.Class({
             this._userManager.disconnect(this._userManagerLoadedId);
             this._userManagerLoadedId = 0;
         }
+        if (this._realmManager) {
+            this._realmManager.disconnect(this._realmSignalId);
+            this._realmSignalId = 0;
+            this._realmManager.release();
+        }
     },
 
     _loadUserList: function() {
