improve index generation and pagerefs