Refactor messages extractor.