Add communication model and fix some bugs