code cleanup and auto scroll chat textarea on new messages