 	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);

		octree->jobCount = 0;
	}
	
	if (octree->animation != NULL)
	{
		free(octree->animation);
		octree->animation = NULL;
		octree->frameCount = octree->boneCount = 0;
	}
	if (octree->d_animation != NULL)
	{
		cudaFree(octree->d_animation);
		octree->d_animation = NULL;
		octree->frameCount = octree->boneCount = 0;
	}
	if (octree->currentFrame != NULL)
	{
		free(octree->currentFrame);

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

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