Terrain Toolkit cant procedural texture a heightmap

Im trying to procedurally texture a hires terrain but the terrain toolkit script tells me it cant process it. how do i get around this? ill post the errors and their scripts. Thanks!

The first error, and the script part.

Texture rectangle is out of bounds UnityEngine.TerrainData:Internal_SetAlphamaps(Int32, Int32, Int32, Int32, Single[,,]) UnityEngine.TerrainData:Internal_SetAlphamaps(Int32, Int32, Int32, Int32, Single[,,])` `textureProgressDelegate("Procedural Terrain Texture", "Generating height and slope maps. Please wait.", 0.1f);

int Tw = terData.heightmapWidth;
        int Th = terData.heightmapHeight;
        float[,] heightMapData = new float[Tw, Th];
        float[,] slopeMapData = new float[Tw, Th];
        float[,,] splatMapData;
        terData.alphamapResolution = Tw;
        splatMapData = terData.GetAlphamaps(0, 0, Tw, Tw);
        // Angles to difference...
        Vector3 terSize = terData.size;
        float slopeBlendMinimum = ((terSize.x / Tw) * Mathf.Tan(slopeBlendMinAngle * Mathf.Deg2Rad)) / terSize.y;
        float slopeBlendMaximum = ((terSize.x / Tw) * Mathf.Tan(slopeBlendMaxAngle * Mathf.Deg2Rad)) / terSize.y;
        try {

its the get alphamaps function.

second, error then script

Texture rectangle is out of bounds UnityEngine.TerrainData:Internal_SetAlphamaps(Int32, Int32, Int32, Int32, Single[,,]) UnityEngine.TerrainData:Internal_SetAlphamaps(Int32, Int32, Int32, Int32, Single[,,]) UnityEngine.TerrainData:SetAlphamaps(Int32, Int32, Single[,,])`

// Generate splat maps...
        textureProgressDelegate("Procedural Terrain Texture", "Generating splat map. Please wait.", 0.9f);
        terData.SetAlphamaps(0, 0, splatMapData);
        // Clean up...
        heightMapData = null;
        slopeMapData = null;
        splatMapData = null;

try to change script code of error function

int Tw = terData.heightmapWidth;
int Th = terData.heightmapHeight;

to

int Tw = terData.heightmapWidth - 1;
int Th = terData.heightmapHeight - 1;