Initial refactoring for scraping