Updated error catching.