Added basic chatting

Also fixed some memory leaks.