refactoring the whole chat to use channels instead of explicit mutexes, lightly tested