 	fread(&result.frameCount, 4, 1, file);
 	fread(&result.boneCount, 4, 1, file);
 
-	result.animation = (Matrix*) malloc(result.frameCount * result.boneCount * sizeof(Matrix));
-	fread(result.animation, sizeof(Matrix), result.frameCount * result.boneCount, file);
+	std::vector< Matrix > animation( result.frameCount * result.boneCount );
+	fread( & animation[ 0 ], sizeof( Matrix ), result.frameCount * result.boneCount, file );
 	result.d_animation = NULL;
 
 	fclose(file);


	if (result.d_animation == NULL)
	{
		cudaMalloc((void**) &(result.d_animation), result.frameCount * result.boneCount * sizeof(Matrix));	
		cudaMemcpy(result.d_animation, result.animation, result.frameCount * result.boneCount * sizeof(Matrix), cudaMemcpyHostToDevice);
	}

	return result;

		cudaFree(octree->d_innerNodes);
		octree->d_innerNodes = NULL;
	}

	if (octree->d_leaves != NULL)
	{
		cudaFree(octree->d_leaves);
