Fixed bugs where client would connect on every request.
Ensure closing of resources.