Refactor and improve AttributeExtraction.