Updating the resource to reflect my final edits (mostly cosmetic) after my migration last year. I've been using this code successfully for 12 months, and my own ad partner has had no issue with it (but clearly I make no warranties about anyone else's).