Fix crashes

Hi,

this fixes my reported OSX crash (issue #1531)
additionally this installs an exception handler to have at least a Stacktrace in the log file, if any crashs might still occur

Markus