build_uri and client cleanup