Refactor app/consumer discovery code