Better way to obtain code index
Various compiler error fixes