clean up the pages generator
fix a couple errors in pages generator