Bug fixes. Fixed index generation