Bug fix when setting index programatically.