DAR-1532: moving the chat code around
DAR-1532: adding missing 'var'
DAR-1532: chat additional error logging