Clean up the code of many examples in minor ways, fix some memory leaks, and avoid the use of dialogs where a regular toplevel works just as well.
This mainly so I can fix deprecation warnings in the page setup dialog.