More bounds checking in calcIndex.