Make client.cpp more modular