Error reporting improvements.

Save reports to config.reportDir and improve error reports by logging stack traces.