Corrected TableBase.selectedIndex calculations