Index: GTP/trunk/Lib/Vis/Preprocessing/scripts/TestPreprocessor.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/scripts/TestPreprocessor.vcproj	(revision 833)
+++ GTP/trunk/Lib/Vis/Preprocessing/scripts/TestPreprocessor.vcproj	(revision 938)
@@ -80,5 +80,5 @@
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="xerces-c_2.lib zdll.lib zziplibd.lib devil.lib qtmain.lib QtOpenGL4.lib QtCored4.lib QtGuid4.lib Qt3Support4.lib QAxContainer.lib glut32.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib Preprocessor.lib"
+				AdditionalDependencies="xerces-c_2.lib zdll.lib zziplib.lib devil.lib qtmain.lib QtOpenGL4.lib QtCored4.lib QtGuid4.lib Qt3Support4.lib QAxContainer.lib glut32.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib Preprocessor.lib"
 				OutputFile="$(OutDir)/Preprocessor.exe"
 				LinkIncremental="1"
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp	(revision 883)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp	(revision 938)
@@ -371,5 +371,5 @@
 
 
-ViewCellsTree::ViewCellsTree(ViewCellsManager *vcm):
+ViewCellsTree::ViewCellsTree(ViewCellsManager *vcm, Environment *env):
 mRoot(NULL),
 mUseAreaForPvs(false),
@@ -381,20 +381,22 @@
 #endif
 {
-	environment->GetBoolValue("ViewCells.Visualization.exportMergedViewCells", mExportMergedViewCells);
-	environment->GetFloatValue("ViewCells.maxStaticMemory", mMaxMemory);
+	env->GetBoolValue("ViewCells.Visualization.exportMergedViewCells", mExportMergedViewCells);
+	env->GetFloatValue("ViewCells.maxStaticMemory", mMaxMemory);
 
 	//-- merge options
-	environment->GetFloatValue("ViewCells.PostProcess.renderCostWeight", mRenderCostWeight);
-	environment->GetIntValue("ViewCells.PostProcess.minViewCells", mMergeMinViewCells);
-	environment->GetFloatValue("ViewCells.PostProcess.maxCostRatio", mMergeMaxCostRatio);
-	environment->GetBoolValue("ViewCells.PostProcess.refine", mRefineViewCells);	
-
-
-	Debug << "========= view cell tree options ================\n";
+	env->GetFloatValue("ViewCells.PostProcess.renderCostWeight", mRenderCostWeight);
+	env->GetIntValue("ViewCells.PostProcess.minViewCells", mMergeMinViewCells);
+	env->GetFloatValue("ViewCells.PostProcess.maxCostRatio", mMergeMaxCostRatio);
+	env->GetBoolValue("ViewCells.PostProcess.refine", mRefineViewCells);	
+
+	env->GetIntValue("ViewCells.PostProcess.maxMergesPerPass", mMaxMergesPerPass);
+	env->GetFloatValue("ViewCells.PostProcess.avgCostMaxDeviation", mAvgCostMaxDeviation);
+
+	Debug << "============= view cell tree options ================\n";
 	Debug << "minimum view cells: " << mMergeMinViewCells << endl;
 	Debug << "max cost ratio: " << mMergeMaxCostRatio << endl;
 	Debug << "max memory: " << mMaxMemory << endl;
 	Debug << "refining view cells: " << mRefineViewCells << endl;
-	Debug << "********* view cell tree options ***************\n";
+	Debug << "============= view cell tree options ================\n";
 
 	MergeCandidate::sRenderCostWeight = mRenderCostWeight;
@@ -555,10 +557,6 @@
 	// maximal ratio of old expected render cost to expected render
 	// when the the render queue has to be reset.
-	float avgCostMaxDeviation;
-	int maxMergesPerPass;
 	int numMergedViewCells = 0;
-	
-	environment->GetIntValue("ViewCells.PostProcess.maxMergesPerPass", maxMergesPerPass);
-	environment->GetFloatValue("ViewCells.PostProcess.avgCostMaxDeviation", avgCostMaxDeviation);
+		
 
 	cout << "actual merge starts now ... " << endl;
@@ -570,11 +568,11 @@
 		//-- reset merge queue if the ratio of current expected cost / real expected cost
 		//   too small or after a given number of merges
-		if ((mergedPerPass > maxMergesPerPass) ||
-			(avgCostMaxDeviation > mAvgRenderCost / realAvgRenderCost))
+		if ((mergedPerPass > mMaxMergesPerPass) ||
+			(mAvgCostMaxDeviation > mAvgRenderCost / realAvgRenderCost))
 		{
 			Debug << "************ reset queue *****************\n"
-				  << "ratios: " << avgCostMaxDeviation 
+				  << "ratios: " << mAvgCostMaxDeviation 
 				  << " real avg render cost " << realAvgRenderCost << " average render cost " << mAvgRenderCost
-				  << " merged per pass : " << mergedPerPass << " of maximal " << maxMergesPerPass << endl;
+				  << " merged per pass : " << mergedPerPass << " of maximal " << mMaxMergesPerPass << endl;
 
 			Debug << "Values before reset: "  
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.h	(revision 931)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.h	(revision 938)
@@ -10,4 +10,5 @@
 class VspBspTree;
 class BoundingBoxConverter;
+class Environment;
 
 class ViewCellsParser : public Parser
@@ -20,5 +21,6 @@
 				 ViewCellsManager **viewCells,
 				 ObjectContainer *objectsm,
-				 BoundingBoxConverter *bconverter);
+				 BoundingBoxConverter *bconverter,
+				 Environment *env);
 };
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 931)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 938)
@@ -33,5 +33,5 @@
 class MergeCandidate;
 class BoundingBoxConverter;
-
+class Environment;
 
 struct BspRay;
@@ -72,12 +72,7 @@
 	enum {PER_OBJECT, PER_TRIANGLE};
 
-	/** Constructor taking the initial and construction samples.
-		@param initialSamples the maximal number of samples used for creating the hierarchy
-		of view cells
-		@param constructionSamples the maximal number of samples used for construction
-	*/
-	ViewCellsManager(const int initialSamples, const int constructionSamples);
-
-	ViewCellsManager();
+	/** default constructor taking an environment file.
+	*/
+	ViewCellsManager(Environment *env);
 
 	virtual ~ViewCellsManager();
@@ -434,6 +429,7 @@
 		@returns the view cells manager if loading was successful, false otherwise
 	*/
-	static ViewCellsManager *LoadViewCells(const string filename, 
+	static ViewCellsManager *LoadViewCells(const string &filename, 
 										   ObjectContainer *objects, 
+										   Environment *env,
 										   BoundingBoxConverter *bconverter = NULL);
 
@@ -559,5 +555,5 @@
 	bool mExportBboxesForPvs;
 		
-
+	Environment *environment;
 	Plane3 mClipPlane;
 
@@ -638,4 +634,6 @@
 	/// if pvs should be exported with view cells
 	bool mExportPvs;
+
+	Environment *mEnvironment;
 };
 
@@ -652,5 +650,5 @@
 		used to construct the bsp tree.
 	*/
-	BspViewCellsManager(BspTree *tree);
+	BspViewCellsManager(BspTree *tree, Environment *env);
 
 	~BspViewCellsManager();
@@ -739,5 +737,5 @@
 public:
 
-	KdViewCellsManager(KdTree *tree);
+	KdViewCellsManager(KdTree *tree, Environment *env);
 
 	int ConstructSubdivision(const ObjectContainer &objects, 
@@ -795,4 +793,6 @@
 	/// depth of the KD tree nodes with represent the view cells
 	int mKdPvsDepth;
+
+
 };
 
@@ -806,5 +806,5 @@
 public:
 
-	VspKdViewCellsManager(VspKdTree *vspKdTree);
+	VspKdViewCellsManager(VspKdTree *vspKdTree, Environment *env);
 
 	int ConstructSubdivision(const ObjectContainer &objects, 
@@ -870,5 +870,5 @@
 public:
 
-	VspBspViewCellsManager(VspBspTree *tree);
+	VspBspViewCellsManager(VspBspTree *tree, Environment *env);
 	~VspBspViewCellsManager();
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp	(revision 904)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp	(revision 938)
@@ -49,5 +49,5 @@
   
   if (optionalParams != NULL)
-    delete optionalParams;
+    DEL_PTR(optionalParams);
 }
 
@@ -312,6 +312,5 @@
 
 int
-Environment::FindOption(const char *name,
-			const bool isFatal) const
+Environment::FindOption(const char *name, const bool isFatal) const
 {
   int i;
@@ -2183,8 +2182,8 @@
 }
 
-void
+bool
 Environment::Parse(const int argc, char **argv, bool useExePath)
 {
-  
+  bool result = true;
   // Read the names of the scene, environment and output files
   ReadCmdlineParams(argc, argv, "");
@@ -2217,4 +2216,5 @@
     // error - bad input file name specified ?
     cerr<<"Error parsing environment file "<<envFilename<<endl;
+	result = false;
   }
   delete envFilename;
@@ -2231,6 +2231,7 @@
     exit(0);
   }
-
-}
-
-}
+  
+  return true;
+}
+
+}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h	(revision 881)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h	(revision 938)
@@ -23,4 +23,5 @@
 class ViewCellsManager;
 class ViewCellLeaf;
+class Environment;
 
 /** Statistics for a view cell partition.
@@ -346,5 +347,5 @@
 
 public:
-	ViewCellsTree(ViewCellsManager *vcm);
+	ViewCellsTree(ViewCellsManager *vcm, Environment *env);
 	~ViewCellsTree();
 
@@ -588,4 +589,6 @@
 	float mMaxMemory;
 
+	int mMaxMergesPerPass;
+	float mAvgCostMaxDeviation;
 };
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 931)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 938)
@@ -356,5 +356,5 @@
 	{
 		environment->GetStringValue("ViewCells.filename", buf);
-		mViewCellsManager = ViewCellsManager::LoadViewCells(buf, &mObjects);
+		mViewCellsManager = ViewCellsManager::LoadViewCells(buf, &mObjects, environment);
 	}
 	else
@@ -395,5 +395,5 @@
 	if (strcmp(name, "kdTree") == 0)
 	{
-		mViewCellsManager = new KdViewCellsManager(mKdTree);
+		mViewCellsManager = new KdViewCellsManager(mKdTree, environment);
 	}
 	else if (strcmp(name, "bspTree") == 0)
@@ -402,5 +402,5 @@
 
 		mBspTree = new BspTree();
-		mViewCellsManager = new BspViewCellsManager(mBspTree);
+		mViewCellsManager = new BspViewCellsManager(mBspTree, environment);
 	}
 	else if (strcmp(name, "vspBspTree") == 0)
@@ -409,5 +409,5 @@
 
 		mVspBspTree = new VspBspTree(environment);
-		mViewCellsManager = new VspBspViewCellsManager(mVspBspTree);
+		mViewCellsManager = new VspBspViewCellsManager(mVspBspTree, environment);
 	}
 	else if (strcmp(name, "vspKdTree") == 0)
@@ -415,5 +415,5 @@
 		mVspKdTree = new VspKdTree();		
 	
-		mViewCellsManager = new VspKdViewCellsManager(mVspKdTree);
+		mViewCellsManager = new VspKdViewCellsManager(mVspKdTree, environment);
 	}
 	else if (strcmp(name, "sceneDependent") == 0)
@@ -424,5 +424,5 @@
 		Debug << "view cell type: Bsp" << endl;
 		
-		mViewCellsManager = new BspViewCellsManager(mBspTree);
+		mViewCellsManager = new BspViewCellsManager(mBspTree, environment);
 	}
 	else
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Environment.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Environment.h	(revision 860)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Environment.h	(revision 938)
@@ -336,5 +336,5 @@
   //@}
 
-  void Parse(const int argc, char **argv, bool useExePath);
+  bool Parse(const int argc, char **argv, bool useExePath);
 
   void
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParserXerces.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParserXerces.h	(revision 931)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParserXerces.h	(revision 938)
@@ -28,5 +28,5 @@
   //  Constructors and Destructor
   // -----------------------------------------------------------------------
-  ViewCellsParseHandlers(ObjectContainer *objects, BoundingBoxConverter *bconverter);
+  ViewCellsParseHandlers(ObjectContainer *objects, BoundingBoxConverter *bconverter, Environment *env);
   ~ViewCellsParseHandlers();
   
@@ -84,4 +84,5 @@
 
   IndexedBoundingBoxContainer mIBoundingBoxes;
+  Environment *mEnvironment;
 
   bool mParseViewCells;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp	(revision 931)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp	(revision 938)
@@ -65,5 +65,7 @@
 //  StdInParseHandlers: Constructors and Destructor
 // ---------------------------------------------------------------------------
-ViewCellsParseHandlers::ViewCellsParseHandlers(ObjectContainer *objects, BoundingBoxConverter *bconverter):
+ViewCellsParseHandlers::ViewCellsParseHandlers(ObjectContainer *objects, 
+											   BoundingBoxConverter *bconverter,
+											   Environment *env):
   mElementCount(0)
   , mAttrCount(0)
@@ -79,4 +81,5 @@
   , mObjects(objects)
   , mBoundingBoxConverter(bconverter)
+  , mEnvironment(env)
 {
 	// mObjects = objects;
@@ -102,4 +105,8 @@
 	  EndViewCells();
 
+  if (element == "BoundingBoxes")
+	  EndBoundingBoxes();
+
+  // inside the view cell description
   if (mParseViewCells)
   {
@@ -150,5 +157,6 @@
 void ViewCellsParseHandlers::EndBoundingBoxes()
 {
-	// bounding boxes gathered: associate object ids with bounding boxes
+	// all bounding boxes gathered in this step => 
+	// associate object ids with bounding boxes
 	if (mBoundingBoxConverter)
 		mBoundingBoxConverter->IdentifyObjects(mIBoundingBoxes, *mObjects);
@@ -605,5 +613,5 @@
 		//mCurrentBspNode = mBspTree->GetRoot();
 
-		mViewCellsManager = new BspViewCellsManager(mBspTree);
+		mViewCellsManager = new BspViewCellsManager(mBspTree, mEnvironment);
 	}
 	else if (strcmp(name, "vspBspTree") == 0)
@@ -613,5 +621,5 @@
 		mVspBspTree = new VspBspTree();
 		//mCurrentBspNode = mVspBspTree->GetRoot();
-		mViewCellsManager = new VspBspViewCellsManager(mVspBspTree);
+		mViewCellsManager = new VspBspViewCellsManager(mVspBspTree, mEnvironment);
 
 		mVspBspTree->mBox = mViewSpaceBox;
@@ -622,5 +630,5 @@
 		// TODO
 		mVspKdTree = new VspKdTree();	
-		mViewCellsManager = new VspKdViewCellsManager(mVspKdTree);
+		mViewCellsManager = new VspKdViewCellsManager(mVspKdTree, mEnvironment);
 	}
 	else
@@ -692,5 +700,6 @@
 								ViewCellsManager **viewCells,
 								ObjectContainer *objects,
-								BoundingBoxConverter *bconverter)
+								BoundingBoxConverter *bconverter,
+								Environment *env)
 {
   // Initialize the XML4C system
@@ -724,5 +733,5 @@
   //  to do.
   //
-  ViewCellsParseHandlers handler(objects, bconverter);
+  ViewCellsParseHandlers handler(objects, bconverter, env);
   parser->setDocumentHandler(&handler);
   parser->setErrorHandler(&handler);
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 931)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 938)
@@ -41,5 +41,5 @@
 
 
-ViewCellsManager::ViewCellsManager():
+ViewCellsManager::ViewCellsManager(Environment *env):
 mRenderer(NULL),
 mInitialSamples(0),
@@ -54,9 +54,10 @@
 mMaxPvsRatio(1.0),
 mViewCellPvsIsUpdated(false)
+,mEnvironment(env)
 {
 	mViewSpaceBox.Initialize();
 	ParseEnvironment();
 
-	mViewCellsTree = new ViewCellsTree(this);
+	mViewCellsTree = new ViewCellsTree(this, env);
 }
 
@@ -65,9 +66,9 @@
 {
 	// visualization stuff
-	environment->GetBoolValue("ViewCells.Visualization.exportRays", mExportRays);
-	environment->GetBoolValue("ViewCells.Visualization.exportGeometry", mExportGeometry);
-	environment->GetFloatValue("ViewCells.maxPvsRatio", mMaxPvsRatio);
-	
-	environment->GetBoolValue("ViewCells.pruneEmptyViewCells", mPruneEmptyViewCells);
+	mEnvironment->GetBoolValue("ViewCells.Visualization.exportRays", mExportRays);
+	mEnvironment->GetBoolValue("ViewCells.Visualization.exportGeometry", mExportGeometry);
+	mEnvironment->GetFloatValue("ViewCells.maxPvsRatio", mMaxPvsRatio);
+	
+	mEnvironment->GetBoolValue("ViewCells.pruneEmptyViewCells", mPruneEmptyViewCells);
 
 	// HACK
@@ -77,30 +78,30 @@
 		mMinPvsSize = 0;
 
-	environment->GetBoolValue("ViewCells.processOnlyValidViewCells", mOnlyValidViewCells);
-
-	environment->GetIntValue("ViewCells.Construction.samples", mConstructionSamples);
-	environment->GetIntValue("ViewCells.PostProcess.samples", mPostProcessSamples);
-	environment->GetBoolValue("ViewCells.PostProcess.useRaysForMerge", mUseRaysForMerge);
-
- 	environment->GetIntValue("ViewCells.Visualization.samples", mVisualizationSamples);
-
-	environment->GetIntValue("ViewCells.Construction.samplesPerPass", mSamplesPerPass);
-	environment->GetBoolValue("ViewCells.exportToFile", mExportViewCells);
-	
-	environment->GetIntValue("ViewCells.active", mNumActiveViewCells);
-	environment->GetBoolValue("ViewCells.PostProcess.compress", mCompressViewCells);
-	environment->GetBoolValue("ViewCells.Visualization.useClipPlane", mUseClipPlaneForViz);
-	environment->GetBoolValue("ViewCells.PostProcess.merge", mMergeViewCells);
-	environment->GetBoolValue("ViewCells.evaluateViewCells", mEvaluateViewCells);
-	environment->GetBoolValue("ViewCells.showVisualization", mShowVisualization);
-	environment->GetIntValue("ViewCells.Filter.maxSize", mMaxFilterSize);
-	environment->GetFloatValue("ViewCells.Filter.width", mFilterWidth);
-	environment->GetIntValue("ViewCells.renderCostEvaluationType", mRenderCostEvaluationType);
-
-	environment->GetBoolValue("ViewCells.exportBboxesForPvs", mExportBboxesForPvs);
-	environment->GetBoolValue("ViewCells.exportPvs", mExportPvs);
+	mEnvironment->GetBoolValue("ViewCells.processOnlyValidViewCells", mOnlyValidViewCells);
+
+	mEnvironment->GetIntValue("ViewCells.Construction.samples", mConstructionSamples);
+	mEnvironment->GetIntValue("ViewCells.PostProcess.samples", mPostProcessSamples);
+	mEnvironment->GetBoolValue("ViewCells.PostProcess.useRaysForMerge", mUseRaysForMerge);
+
+ 	mEnvironment->GetIntValue("ViewCells.Visualization.samples", mVisualizationSamples);
+
+	mEnvironment->GetIntValue("ViewCells.Construction.samplesPerPass", mSamplesPerPass);
+	mEnvironment->GetBoolValue("ViewCells.exportToFile", mExportViewCells);
+	
+	mEnvironment->GetIntValue("ViewCells.active", mNumActiveViewCells);
+	mEnvironment->GetBoolValue("ViewCells.PostProcess.compress", mCompressViewCells);
+	mEnvironment->GetBoolValue("ViewCells.Visualization.useClipPlane", mUseClipPlaneForViz);
+	mEnvironment->GetBoolValue("ViewCells.PostProcess.merge", mMergeViewCells);
+	mEnvironment->GetBoolValue("ViewCells.evaluateViewCells", mEvaluateViewCells);
+	mEnvironment->GetBoolValue("ViewCells.showVisualization", mShowVisualization);
+	mEnvironment->GetIntValue("ViewCells.Filter.maxSize", mMaxFilterSize);
+	mEnvironment->GetFloatValue("ViewCells.Filter.width", mFilterWidth);
+	mEnvironment->GetIntValue("ViewCells.renderCostEvaluationType", mRenderCostEvaluationType);
+
+	mEnvironment->GetBoolValue("ViewCells.exportBboxesForPvs", mExportBboxesForPvs);
+	mEnvironment->GetBoolValue("ViewCells.exportPvs", mExportPvs);
 
 	char buf[100];
-	environment->GetStringValue("ViewCells.samplingType", buf);
+	mEnvironment->GetStringValue("ViewCells.samplingType", buf);
 
 	
@@ -119,5 +120,5 @@
 	}
 
-	environment->GetStringValue("ViewCells.Evaluation.samplingType", buf);
+	mEnvironment->GetStringValue("ViewCells.Evaluation.samplingType", buf);
 	
 	if (strcmp(buf, "box") == 0)
@@ -135,5 +136,5 @@
 	}
 
-	environment->GetStringValue("ViewCells.renderCostEvaluationType", buf);
+	mEnvironment->GetStringValue("ViewCells.renderCostEvaluationType", buf);
 	
 	if (strcmp(buf, "perobject") == 0)
@@ -151,5 +152,5 @@
 	}
 
-    environment->GetStringValue("ViewCells.Visualization.colorCode", buf);
+    mEnvironment->GetStringValue("ViewCells.Visualization.colorCode", buf);
 
 	if (strcmp(buf, "PVS") == 0)
@@ -719,9 +720,9 @@
 	char s[64]; 
 
-	environment->GetIntValue("ViewCells.Evaluation.samplesPerPass", samplesPerPass);
-	environment->GetIntValue("ViewCells.Evaluation.samples", numSamples);
+	mEnvironment->GetIntValue("ViewCells.Evaluation.samplesPerPass", samplesPerPass);
+	mEnvironment->GetIntValue("ViewCells.Evaluation.samples", numSamples);
 
 	char statsPrefix[100];
-	environment->GetStringValue("ViewCells.Evaluation.statsPrefix", statsPrefix);
+	mEnvironment->GetStringValue("ViewCells.Evaluation.statsPrefix", statsPrefix);
 
 	Debug << "view cell evaluation samples per pass: " << samplesPerPass << endl;
@@ -813,6 +814,6 @@
 	int histoPasses;
 
-	environment->GetBoolValue("ViewCells.Evaluation.histogram", useHisto);
-	environment->GetIntValue("ViewCells.Evaluation.histoPasses", histoPasses);
+	mEnvironment->GetBoolValue("ViewCells.Evaluation.histogram", useHisto);
+	mEnvironment->GetIntValue("ViewCells.Evaluation.histoPasses", histoPasses);
 
 	const int numLeaves = mViewCellsTree->GetNumInitialViewCells(mViewCellsTree->GetRoot());
@@ -1162,5 +1163,5 @@
 	X3dParser parser;
 
-	environment->GetFloatValue("ViewCells.height", parser.mViewCellHeight);
+	mEnvironment->GetFloatValue("ViewCells.height", parser.mViewCellHeight);
 
 	bool success = parser.ParseFile(filename, *this);
@@ -1588,10 +1589,10 @@
 	float pos;
 
-	environment->GetFloatValue("ViewCells.Visualization.clipPlanePos", pos);
+	mEnvironment->GetFloatValue("ViewCells.Visualization.clipPlanePos", pos);
 
 	Vector3 point = mViewSpaceBox.Min() +  mViewSpaceBox.Size() * pos;
 
 	if (mUseClipPlaneForViz)
-        environment->GetIntValue("ViewCells.Visualization.clipPlaneAxis", axis);
+        mEnvironment->GetIntValue("ViewCells.Visualization.clipPlaneAxis", axis);
 
 	Vector3 normal(0,0,0);
@@ -2063,8 +2064,8 @@
 
 
-BspViewCellsManager::BspViewCellsManager(BspTree *bspTree):
-ViewCellsManager(), mBspTree(bspTree)
-{
-	environment->GetIntValue("BspTree.Construction.samples", mInitialSamples);
+BspViewCellsManager::BspViewCellsManager(BspTree *bspTree, Environment *env):
+ViewCellsManager(env), mBspTree(bspTree)
+{
+	mEnvironment->GetIntValue("BspTree.Construction.samples", mInitialSamples);
 	mBspTree->SetViewCellsManager(this);
 	mBspTree->mViewCellsTree = mViewCellsTree;
@@ -2234,5 +2235,5 @@
 	{
 		char mstats[100];
-		environment->GetStringValue("ViewCells.mergeStats", mstats);
+		mEnvironment->GetStringValue("ViewCells.mergeStats", mstats);
 		mViewCellsTree->ExportStats(mstats);
 	}
@@ -2318,5 +2319,5 @@
 	{
 		char filename[100];
-		environment->GetStringValue("ViewCells.filename", filename);
+		mEnvironment->GetStringValue("ViewCells.filename", filename);
 		ExportViewCells(filename, mExportPvs, objects);
 	}
@@ -2326,5 +2327,5 @@
 	{
 		char filename[100];
-		environment->GetStringValue("ViewCells.boxesFilename", filename);
+		mEnvironment->GetStringValue("ViewCells.boxesFilename", filename);
 		ExportBoundingBoxes(filename, objects);
 	}
@@ -2386,5 +2387,5 @@
 	//-- visualization of the BSP splits
 	bool exportSplits = false;
-	environment->GetBoolValue("BspTree.Visualization.exportSplits", exportSplits);
+	mEnvironment->GetBoolValue("BspTree.Visualization.exportSplits", exportSplits);
 
 	if (exportSplits)
@@ -2933,6 +2934,6 @@
 
 
-KdViewCellsManager::KdViewCellsManager(KdTree *kdTree):
-ViewCellsManager(), mKdTree(kdTree), mKdPvsDepth(100)
+KdViewCellsManager::KdViewCellsManager(KdTree *kdTree, Environment *env):
+ViewCellsManager(env), mKdTree(kdTree), mKdPvsDepth(100)
 {
 }
@@ -3237,8 +3238,8 @@
 
 
-VspKdViewCellsManager::VspKdViewCellsManager(VspKdTree *vspKdTree):
-ViewCellsManager(), mVspKdTree(vspKdTree)
-{
-	environment->GetIntValue("VspKdTree.Construction.samples", mInitialSamples);
+VspKdViewCellsManager::VspKdViewCellsManager(VspKdTree *vspKdTree, Environment *env):
+ViewCellsManager(env), mVspKdTree(vspKdTree)
+{
+	mEnvironment->GetIntValue("VspKdTree.Construction.samples", mInitialSamples);
 	mVspKdTree->SetViewCellsManager(this);
 }
@@ -3598,8 +3599,8 @@
 
 
-VspBspViewCellsManager::VspBspViewCellsManager(VspBspTree *vspBspTree):
-ViewCellsManager(), mVspBspTree(vspBspTree)
-{
-	environment->GetIntValue("VspBspTree.Construction.samples", mInitialSamples);
+VspBspViewCellsManager::VspBspViewCellsManager(VspBspTree *vspBspTree, Environment *env):
+ViewCellsManager(env), mVspBspTree(vspBspTree)
+{
+	mEnvironment->GetIntValue("VspBspTree.Construction.samples", mInitialSamples);
 	mVspBspTree->SetViewCellsManager(this);
 	mVspBspTree->mViewCellsTree = mViewCellsTree;
@@ -3756,5 +3757,5 @@
 		ObjectPvs pvs;
 
-		environment->GetStringValue("ViewCells.mergeStats", mstats);
+		mEnvironment->GetStringValue("ViewCells.mergeStats", mstats);
 		mViewCellsTree->ExportStats(mstats);
 	}
@@ -4010,5 +4011,5 @@
 	{
 		char filename[100];
-		environment->GetStringValue("ViewCells.filename", filename);
+		mEnvironment->GetStringValue("ViewCells.filename", filename);
 		ExportViewCells(filename, mExportPvs, objects);
 	}
@@ -4019,5 +4020,5 @@
 	{
 		char filename[100];
-		environment->GetStringValue("ViewCells.boxesFilename", filename);
+		mEnvironment->GetStringValue("ViewCells.boxesFilename", filename);
 	
 		ExportBoundingBoxes(filename, objects);
@@ -4320,5 +4321,5 @@
 	//-- visualization of the BSP splits
 	bool exportSplits = false;
-	environment->GetBoolValue("VspBspTree.Visualization.exportSplits", exportSplits);
+	mEnvironment->GetBoolValue("VspBspTree.Visualization.exportSplits", exportSplits);
 
 	if (exportSplits)
@@ -4723,6 +4724,7 @@
 
 
-ViewCellsManager *ViewCellsManager::LoadViewCells(const string filename, 
+ViewCellsManager *ViewCellsManager::LoadViewCells(const string &filename, 
 												  ObjectContainer *objects,
+												  Environment *env,
 												  BoundingBoxConverter *bconverter)
 {
@@ -4731,10 +4733,9 @@
 	ViewCellsManager *vm = NULL;
 
-	Debug << "vc filename: " << filename << endl;
-
+	Debug << "here23 filename: " << filename << endl;
 	//BoundingBoxConverter bconverter;
 
-	if (parser.ParseFile(filename, &vm, objects, bconverter))
-	{
+	if (parser.ParseFile(filename, &vm, objects, bconverter, env))
+	{Debug << "here25 filename: " << filename << endl;
 		//vm->PrepareLoadedViewCells();
 		vm->ResetViewCells();
