remove trailing ^M
remove trailing space
fix same topic first and last message