Fixed some bugs about communication and protocol