diff --git a/src/config.py b/src/config.py
index 103d9c6ac007ebb9ea00b55a861710f47806d2ef..f6367ffbf90bab002e6ea6d45a5fd804ade9bb67 100644
--- a/src/config.py
+++ b/src/config.py
@@ -1384,14 +1384,14 @@ class AccountsWindow:
 				gobject.timeout_add(500, login, self.current_account, show_before,
 					status_before)
 
+			def on_yes(checked):
+				relog()
+			def on_no():
+				if self.resend_presence:
+					self.resend()
 			self.dialog = dialogs.YesNoDialog(_('Relogin now?'),
 				_('If you want all the changes to apply instantly, '
-				'you must relogin.'))
-			resp = self.dialog.get_response()
-			if resp == gtk.RESPONSE_YES:
-				relog()
-			elif self.resend_presence:
-				self.resend()
+				'you must relogin.'), on_response_yes=on_yes, on_response_no=on_no)
 		elif self.resend_presence:
 			self.resend()
 
diff --git a/src/gajim.py b/src/gajim.py
index 134152b162206d6d86d084c48609182a24be3440..d520b9f42521f15d70ce1ffbaf2ce6c9c1cf5959 100755
--- a/src/gajim.py
+++ b/src/gajim.py
@@ -1855,20 +1855,18 @@ class Interface:
 			self.instances[account]['privacy_lists'].privacy_list_removed(name)
 
 	def handle_event_zc_name_conflict(self, account, data):
-		dlg = dialogs.InputDialog(_('Username Conflict'),
-			_('Please type a new username for your local account'),
-			is_modal = True)
-		dlg.input_entry.set_text(data)
-		response = dlg.get_response()
-		if response == gtk.RESPONSE_OK:
-			new_name = dlg.input_entry.get_text()
+		def on_ok(new_name):
 			gajim.config.set_per('accounts', account, 'name', new_name)
 			status = gajim.connections[account].status
 			gajim.connections[account].username = new_name
 			gajim.connections[account].change_status(status, '')
-		else:
+		def on_cancel():
 			gajim.connections[account].change_status('offline','')
 
+		dlg = dialogs.InputDialog(_('Username Conflict'),
+			_('Please type a new username for your local account'), input_str=data,
+			is_modal=True, ok_handler=on_ok, cancel_handler=on_cancel)
+
 	def handle_event_ping_sent(self, account, contact):
 		if contact.jid == contact.get_full_jid():
 			# If contact is a groupchat user