Some critical fixes in chat adapter
Logical fixes in roster and history generator