a bunch of small refactorings in the dialog module