Minor code reformatting.
Minor code reformatting.
Added logic to better ensure thread shutdown when exceptions are encountered.