Logging fixes

Log exceptions properly and generate a 500 page.