Probably it's not the worst idea to close the DB before exit...
Added minimal console logging -> this is the contents of the cron mail!
Improved error logging
Added some more info messages to trace what's happening