Remove excess new lines from the ends of messages
Removed extract attributes code to a new class