see client.cc comments regarding scope of variables.