Revamp the extraction algorithm and write comments to document it.