Switch to JSON.  Split the address filtering logic into a separate tool.