Better error catching, ref #1978