Refactored sitemap generator code