Work towards modular client.cpp
Finish modularizing client.cpp