Minor refactoring of chat + misc tweaks