Added more logging for exception handling.