Dramatically reduced the number of queries needed for index sitemap generation (from 72 to 15 on my test data).
Remove some obsolete code and an obsolete function
Add some inline documentation