added some improvements to support implementing chat in tbs