CONN-677

Added StreamUtils to handle proper opening and closing of streams.

Also, some minor code clean-up for readability.