Dialog code polished