Code improvements

* easier variable scoping
* moving some methods where they “belong”
* introducing wppt_source_url and wppt_source_name fields, used in
attribution and to link images back to source