Refactor the entity extractor.