Fix bug where uncaught exceptions where not logged correctly