Refactoring and bug fixes

Pulled a lot of the scrape code out into private functions. Fixed a couple of unicode bugs with the URLs.