Add comments and fix a bug in sending message