Moar refactor stuff for chat example.