Fixed bug in index creation.