Optimized client.cpp and client.h