Some refactoring around dialogs.