removed trailing whitespaces, refactored ChatMessage