Initial index build code