Fixed a database cleanup function.
Fix of misc bugs, perhaps to do with Qt5 on my new laptop.