Added much more exception trapping.