Adjusted logging and error handling a bit