Make error catching less crashy; make logging more consistent