Corrected numerous bugs in createIndex, implemented loadIndex