Fix bugs in chat