Use dialogs, fixed a few bugs