Reorganized code to separate extraction from conversion