Fixed a number of issues with the generic dialog code. Also implemented
some missing features such as what to do when a user clicks the close
button
Tiny fix in the mainframe and some cleaning up