Moved code from client.cc to other files for better management.