diff --git a/NIF_Blocks.cpp b/NIF_Blocks.cpp
index 9dd0c3bb80d3f945e560a6e0f8d2e99efd849669..60d6d547fe5d4e8657774d8ee641abca840ade7b 100644
--- a/NIF_Blocks.cpp
+++ b/NIF_Blocks.cpp
@@ -776,6 +776,9 @@ void * AShapeData::QueryInterface( int id ) {
 }
 
 void AShapeData::SetVertexCount(int n) {
+	if ( n > 65535 || n < 0 )
+		throw runtime_error("Invalid Vertex Count: must be between 0 and 65535.");
+
 	if ( n == 0 ) {
 		vertices.clear();
 		normals.clear();
@@ -785,7 +788,7 @@ void AShapeData::SetVertexCount(int n) {
 		}
 		return;
 	}
-
+	
 	//n != 0
 	vertices.resize(n);
 
@@ -1128,14 +1131,20 @@ void * NiTriShapeData::QueryInterface( int id ) {
 }
 
 void NiTriShapeData::SetTriangleCount(int n) {
-	triangles.resize(n);
+	if ( n > 65535 || n < 0 )
+		throw runtime_error("Invalid Triangle Count: must be between 0 and 65535.");
+
+	if ( n == 0 )
+		triangles.clear();
+	else
+		triangles.resize(n);
 }
 
 //--Setters--//
 
 void NiTriShapeData::SetTriangles( const vector<Triangle> & in ) {
-	if (in.size() != vertices.size())
-		throw runtime_error("Vector size must equal Vertex Count.  Call SetVertexCount() to resize.");
+	if (in.size() != triangles.size())
+		throw runtime_error("Vector size must equal Triangle Count.  Call SetTriangleCount() to resize.");
 	triangles = in;
 }