Refactor special purposes index creation out to functions.