Added an errorhandler, so the app will at least log an error before it dies