Fix for multiple concurrency issues with chats/messages

You'll probably want this as it fixes about 3 different bugs, some of which were causing crashes.