Added more exception catching.