Fixed a strange bug in calcIndex and calcTargets where x and y values were swapped.