moved indexing code to IndexBuffer.cpp