Refactor and fix minor typo in sitemap code