Fixing some of the bugs and adding the index option.