major refactor to support multiple client instances with different authentications