Add a dialog for creating new profiles. Fix some bugs.