Partially cleaned parserOfMessages function