We also clean things up a bit and check for error messages, which now can cause exceptions which should invoke cleanup.