Deduplication of code in messages.cpp
Merge pull request #4 from dkreuter/master

Deduplication of code in messages.cpp