Manually merged IM chat fixes from master branch.

Master commits:
0568e14eff2e4b71795483008b91ad594e11df03
324f138efb9793393eebb05da958e41056f05297

IM chat is compatible with server WCS-2.1 build 271+