correct a couple of misuses of array elements already stored in variables
I think I earlier forgot to include changes to the database schema.  Also restructure the DOM filter in preparation for separating URL replacement into a separate step.  The reworking of extract.tpl is half-finished and not close to working.
Forgot to include this new template for fixing the URLs (which isn't yet used)
Fix broken template