New chat module

This patch implements a new chat system for instant messages.