Modularized the communication protocol into classes