Chat handling rewritten.