Refactor parts handling in message parsing.