Added bounds checking to setThreadArray/setThreadDims