Fixed a bug that has been causing random seg faults due to array index mis-match when it is passed to a routine