Better error dialogs, some light code restructuring.