added exception catching for a few exceptions.