Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/SceneEntity.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/SceneEntity.h	(revision 2769)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/SceneEntity.h	(revision 2776)
@@ -7,5 +7,5 @@
 
 
-namespace CHCDemo 
+namespace CHCDemoEngine 
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/Geometry.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/Geometry.h	(revision 2773)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/Geometry.h	(revision 2776)
@@ -7,5 +7,5 @@
 
 
-namespace CHCDemo 
+namespace CHCDemoEngine 
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/Texture.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/Texture.cpp	(revision 2769)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/Texture.cpp	(revision 2776)
@@ -9,5 +9,5 @@
 
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/Material.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/Material.h	(revision 2769)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/Material.h	(revision 2776)
@@ -3,5 +3,5 @@
 
 
-namespace CHCDemo 
+namespace CHCDemoEngine 
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/Matrix4x4.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/Matrix4x4.h	(revision 2756)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/Matrix4x4.h	(revision 2776)
@@ -5,5 +5,5 @@
 
 
-namespace CHCDemo 
+namespace CHCDemoEngine 
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/RenderTraverser.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/RenderTraverser.cpp	(revision 2775)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/RenderTraverser.cpp	(revision 2776)
@@ -6,4 +6,5 @@
 #include "RenderState.h"
 #include "Geometry.h"
+#include "Timer/PerfTimer.h"
 
 
@@ -11,5 +12,5 @@
 
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
@@ -87,8 +88,7 @@
 	if (node->GetLastRenderedFrame() != mFrameId)
 	{
-		if (!mUseRenderQueue)
-			if (mRenderState->SetState(RenderState::RENDER))
-				++ mStats.mNumStateChanges;
-
+		if (mRenderState->SetState(RenderState::RENDER))
+			++ mStats.mNumStateChanges;
+		
 		node->SetLastRenderedFrame(mFrameId);
 
@@ -128,8 +128,11 @@
 void RenderTraverser::RenderScene()
 {
-	InitTiming();
-	long t1, t2;
-
-	t1 = GetTime();
+	PerfTimer timer;
+
+	timer.Start();
+
+	//InitTiming();
+	//long t1, t2;
+	//t1 = GetTime();
 
 	glEnableClientState(GL_VERTEX_ARRAY);
@@ -156,6 +159,7 @@
 	glDisableClientState(GL_NORMAL_ARRAY);
 
-	t2 = GetTime();
-	mStats.mRenderTime = TimeDiff(t1, t2);
+	//t2 = GetTime();
+	//mStats.mRenderTime = TimeDiff(t1, t2);
+	mStats.mRenderTime = timer.Elapsedms();
 }
 
@@ -180,5 +184,24 @@
 
 
-#if 0
+void RenderTraverser::SetAssumedVisibleFrames(int assumedVisibleFrames)
+{
+	mAssumedVisibleFrames = assumedVisibleFrames;
+}
+
+
+void RenderTraverser::SetMaxBatchSize(int batchSize)
+{
+	mMaxBatchSize = batchSize;
+}
+
+
+void RenderTraverser::SetUseMultiQueries(bool useMultiQueries)
+{
+	mUseMultiQueries = useMultiQueries;
+	std::cout << "using multiqueries: " << mUseMultiQueries << std::endl;
+}
+
+
+
 OcclusionQuery *RenderTraverser::IssueOcclusionQuery(BvhNode *node, bool wasVisible)
 {
@@ -191,8 +214,6 @@
 }
 
-#else
-
-
-OcclusionQuery *RenderTraverser::IssueOcclusionQuery(BvhNode *node, bool wasVisible)
+
+void RenderTraverser::IssueOcclusionQuery(const OcclusionQuery &query, bool wasVisible)
 {
 	++ mStats.mNumIssuedQueries;
@@ -200,14 +221,10 @@
 	if (mUseRenderQueue && (mRenderState->GetMode() == RenderState::RENDER))
 	{
+		//cout << "render queue: " << mRenderQueue.GetSize() << endl;
 		mRenderQueue.Render();
 		mRenderQueue.Clear();
 	}
 
-	OcclusionQuery *query = mQueryHandler.RequestQuery();
-
-	query->Reset();
-	query->AddNode(node);
-
-	query->BeginQuery();
+	query.BeginQuery();
 
 	if (wasVisible)
@@ -218,5 +235,6 @@
 	if (wasVisible && mUseOptimization)
 	{
-		RenderNode(node);
+		for (size_t i = 0; i < query.GetSize(); ++ i)
+			RenderNode(query.GetNodes()[i]);
 	}
 	else
@@ -226,41 +244,4 @@
 			++ mStats.mNumStateChanges;
 
-		mBvh->RenderBoundingBox(node, mRenderState);
-	}
-
-	query->EndQuery();
-
-	return query;
-}
-
-#endif
-void RenderTraverser::IssueOcclusionQuery(const OcclusionQuery &query, bool wasVisible)
-{
-	++ mStats.mNumIssuedQueries;
-
-	if (mUseRenderQueue && (mRenderState->GetMode() == RenderState::RENDER))
-	{
-		mRenderQueue.Render();
-		mRenderQueue.Clear();
-	}
-
-	query.BeginQuery();
-
-	if (wasVisible)
-		++ mStats.mNumPreviouslyVisibleNodeQueries;
-
-	// if this node is a previous visible leaf:
-	// leaves will be rendered anyway => we can also test with the real geometry 
-	if (wasVisible && mUseOptimization)
-	{
-		for (size_t i = 0; i < query.GetSize(); ++ i)
-			RenderNode(query.GetNodes()[i]);
-	}
-	else
-	{
-		// change to query mode and render box
-		if (mRenderState->SetState(RenderState::QUERY))
-			++ mStats.mNumStateChanges;
-
 		mBvh->RenderBoundingBoxes(query.GetNodes(), mRenderState);
 	}
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/Plane3.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/Plane3.cpp	(revision 2762)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/Plane3.cpp	(revision 2776)
@@ -3,5 +3,5 @@
 
 
-namespace CHCDemo 
+namespace CHCDemoEngine 
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/OcclusionQuery.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/OcclusionQuery.cpp	(revision 2773)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/OcclusionQuery.cpp	(revision 2776)
@@ -6,5 +6,5 @@
 
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/SceneQuery.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/SceneQuery.h	(revision 2764)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/SceneQuery.h	(revision 2776)
@@ -5,5 +5,5 @@
 #include "AxisAlignedBox3.h"
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/AxisAlignedBox3.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/AxisAlignedBox3.h	(revision 2755)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/AxisAlignedBox3.h	(revision 2776)
@@ -7,5 +7,5 @@
 
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/Vector3.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/Vector3.h	(revision 2762)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/Vector3.h	(revision 2776)
@@ -7,5 +7,5 @@
 
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/Geometry.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/Geometry.cpp	(revision 2773)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/Geometry.cpp	(revision 2776)
@@ -5,5 +5,5 @@
 
 
-namespace CHCDemo 
+namespace CHCDemoEngine 
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/Camera.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/Camera.h	(revision 2764)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/Camera.h	(revision 2776)
@@ -7,5 +7,5 @@
 
 
-namespace CHCDemo 
+namespace CHCDemoEngine 
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/Texture.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/Texture.h	(revision 2768)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/Texture.h	(revision 2776)
@@ -8,5 +8,5 @@
 #include <string>
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/Visualization.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/Visualization.h	(revision 2767)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/Visualization.h	(revision 2776)
@@ -5,5 +5,5 @@
 
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/BvhLoader.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/BvhLoader.cpp	(revision 2773)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/BvhLoader.cpp	(revision 2776)
@@ -8,5 +8,5 @@
 
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/RenderState.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/RenderState.cpp	(revision 2773)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/RenderState.cpp	(revision 2776)
@@ -5,5 +5,5 @@
 
 
-namespace CHCDemo 
+namespace CHCDemoEngine 
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/SceneQuery.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/SceneQuery.cpp	(revision 2764)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/SceneQuery.cpp	(revision 2776)
@@ -9,5 +9,5 @@
 
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/RenderQueue.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/RenderQueue.cpp	(revision 2773)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/RenderQueue.cpp	(revision 2776)
@@ -9,5 +9,5 @@
 
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
@@ -15,4 +15,5 @@
 inline static bool IsLower(SceneEntity *ent1, SceneEntity *ent2)
 {
+	// group by texture size
 	Texture *t1 = ent1->GetMaterial()->GetTexture();
 	Texture *t2 = ent2->GetMaterial()->GetTexture();
@@ -21,4 +22,5 @@
 	int tsize2 = t2 ? t2->GetByteSize() : 0;
 
+	// if texture size equal, group by material
 	if (tsize1 == tsize2)
 		return ent1->GetMaterial() < ent2->GetMaterial();
@@ -28,5 +30,5 @@
 
 
-RenderQueue::RenderQueue(): mState(NULL), mMinSizeForSorting(5)
+RenderQueue::RenderQueue(): mState(NULL), mMinSizeForSorting(3)
 {
 }
@@ -63,5 +65,4 @@
 		Sort();
 	
-	//if (!mEntities.empty()) Debug << "rendering render queue" << endl;
 	SceneEntityContainer::const_iterator sit, sit_end = mEntities.end();
 
@@ -70,9 +71,4 @@
 		SceneEntity *ent = *sit;
 		ent->Render(mState);
-
-		/*if (ent->GetMaterial()->GetTexture())
-			Debug << " " << ent->GetMaterial()->GetTexture()->GetWidth();
-		else
-			Debug << " 0";*/
 	}
 }
@@ -81,12 +77,5 @@
 void RenderQueue::Sort()
 {
-	//InitTiming();
-	//long t1, t2;
-	//t1 = GetTime();
-
 	sort(mEntities.begin(), mEntities.end(), IsLower);
-
-	//t2 = GetTime();
-	//cout << "sort: " << TimeDiff(t1, t2) << endl;
 }
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/Bvh.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/Bvh.h	(revision 2775)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/Bvh.h	(revision 2776)
@@ -10,5 +10,5 @@
 
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
@@ -240,5 +240,5 @@
 
 
-void BvhNode::SetVisible(const bool visible) 
+void BvhNode::SetVisible(bool visible) 
 { 
 	mVisibility.mIsVisible = visible; 
@@ -258,5 +258,5 @@
 
 
-void BvhNode::SetTimesTestedInvisible(const int t) 
+void BvhNode::SetTimesTestedInvisible(int t) 
 { 
 	mVisibility.mTimesInvisible = t; 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/Vector3.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/Vector3.cpp	(revision 2751)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/Vector3.cpp	(revision 2776)
@@ -5,5 +5,5 @@
 
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/Plane3.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/Plane3.h	(revision 2762)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/Plane3.h	(revision 2776)
@@ -5,5 +5,5 @@
 
 
-namespace CHCDemo 
+namespace CHCDemoEngine 
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/Triangle3.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/Triangle3.cpp	(revision 2751)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/Triangle3.cpp	(revision 2776)
@@ -8,5 +8,5 @@
 
 
-namespace CHCDemo {
+namespace CHCDemoEngine {
 
 	
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/OcclusionQuery.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/OcclusionQuery.h	(revision 2773)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/OcclusionQuery.h	(revision 2776)
@@ -6,5 +6,5 @@
 
 
-namespace CHCDemo 
+namespace CHCDemoEngine 
 { 
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/CHCTraverser.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/CHCTraverser.h	(revision 2771)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/CHCTraverser.h	(revision 2776)
@@ -5,5 +5,5 @@
 
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/StopAndWaitTraverser.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/StopAndWaitTraverser.h	(revision 2767)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/StopAndWaitTraverser.h	(revision 2776)
@@ -5,5 +5,5 @@
 
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/Visualization.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/Visualization.cpp	(revision 2771)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/Visualization.cpp	(revision 2776)
@@ -10,5 +10,5 @@
 
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/CHCPlusPlusTraverser.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/CHCPlusPlusTraverser.h	(revision 2773)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/CHCPlusPlusTraverser.h	(revision 2776)
@@ -5,5 +5,5 @@
 
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/BvhLoader.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/BvhLoader.h	(revision 2760)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/BvhLoader.h	(revision 2776)
@@ -7,5 +7,5 @@
 
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/Bvh.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/Bvh.cpp	(revision 2775)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/Bvh.cpp	(revision 2776)
@@ -15,5 +15,5 @@
 
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/BinaryLoader.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/BinaryLoader.h	(revision 2764)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/BinaryLoader.h	(revision 2776)
@@ -11,5 +11,5 @@
 
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/RenderState.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/RenderState.h	(revision 2773)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/RenderState.h	(revision 2776)
@@ -6,5 +6,5 @@
 
 
-namespace CHCDemo 
+namespace CHCDemoEngine 
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/FrustumCullingTraverser.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/FrustumCullingTraverser.h	(revision 2767)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/FrustumCullingTraverser.h	(revision 2776)
@@ -5,5 +5,5 @@
 
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/common.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/common.cpp	(revision 2772)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/common.cpp	(revision 2776)
@@ -26,5 +26,5 @@
 
 
-namespace CHCDemo 
+namespace CHCDemoEngine 
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/RenderQueue.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/RenderQueue.h	(revision 2773)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/RenderQueue.h	(revision 2776)
@@ -4,5 +4,5 @@
 #include "common.h"
 
-namespace CHCDemo 
+namespace CHCDemoEngine 
 {
 
@@ -36,4 +36,5 @@
 	void Clear();
 
+	int GetSize() const { return (int)mEntities.size(); }
 
 protected:
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/SceneEntity.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/SceneEntity.cpp	(revision 2773)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/SceneEntity.cpp	(revision 2776)
@@ -6,5 +6,5 @@
 
 
-namespace CHCDemo 
+namespace CHCDemoEngine 
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/CHCTraverser.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/CHCTraverser.cpp	(revision 2770)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/CHCTraverser.cpp	(revision 2776)
@@ -3,5 +3,5 @@
 
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
@@ -27,4 +27,5 @@
 			{
 				BvhNode *node = query->GetFrontNode();
+				node->SetAssumedVisibleFrameId(mFrameId + mAssumedVisibleFrames);
 
 				node->SetVisible(true);
@@ -34,4 +35,5 @@
 			else
 			{
+				
 				++ mStats.mNumQueryCulledNodes;
 			}
@@ -63,8 +65,6 @@
 					
 					// identify nodes that we cannot skip queries for
-					const bool leafOrWasInvisible = (!wasVisible || node->IsVirtualLeaf());
-
-					// reset node's visibility classification 
-					node->SetVisible(false);
+					const bool testFeasible = (!wasVisible || 
+						(node->IsVirtualLeaf() && (node->GetAssumedVisibleFrameId() <= mFrameId)));
 
 					// update node's visited flag
@@ -72,9 +72,22 @@
 					
 					// skip testing previously visible interior nodes
-					if (leafOrWasInvisible)
+					if (testFeasible)
 					{
 						OcclusionQuery *query = IssueOcclusionQuery(node, wasVisible);
 						mQueryQueue.push(query);
 					}
+					else
+					{
+						if (node->IsVirtualLeaf())
+						{
+							node->SetVisible(true);
+							mBvh->MakeParentsVisible(node);
+						} 
+						else // reset visibility classification
+						{
+							node->SetVisible(false);
+						}
+					}
+
 					
 					// always traverse a node if it was visible
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/StopAndWaitTraverser.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/StopAndWaitTraverser.cpp	(revision 2767)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/StopAndWaitTraverser.cpp	(revision 2776)
@@ -3,5 +3,5 @@
 
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/chc_revisited.vcproj
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/chc_revisited.vcproj	(revision 2769)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/chc_revisited.vcproj	(revision 2776)
@@ -268,4 +268,44 @@
 				>
 			</File>
+			<Filter
+				Name="timer"
+				>
+				<File
+					RelativePath=".\Timer\BenchTimer.cpp"
+					>
+				</File>
+				<File
+					RelativePath=".\Timer\BenchTimer.h"
+					>
+				</File>
+				<File
+					RelativePath=".\Timer\merror.cpp"
+					>
+				</File>
+				<File
+					RelativePath=".\Timer\merror.h"
+					>
+				</File>
+				<File
+					RelativePath=".\Timer\mstring.h"
+					>
+				</File>
+				<File
+					RelativePath=".\Timer\PerfTimer.h"
+					>
+				</File>
+				<File
+					RelativePath=".\Timer\PerfTimerSkeleton.h"
+					>
+				</File>
+				<File
+					RelativePath=".\Timer\RDTSCTimer.cpp"
+					>
+				</File>
+				<File
+					RelativePath=".\Timer\RDTSCTimer.h"
+					>
+				</File>
+			</Filter>
 		</Filter>
 		<Filter
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/Triangle3.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/Triangle3.h	(revision 2751)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/Triangle3.h	(revision 2776)
@@ -5,5 +5,5 @@
 
 
-namespace CHCDemo 
+namespace CHCDemoEngine 
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/Material.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/Material.cpp	(revision 2769)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/Material.cpp	(revision 2776)
@@ -6,5 +6,5 @@
 
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/chcdemo.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/chcdemo.cpp	(revision 2774)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/chcdemo.cpp	(revision 2776)
@@ -22,6 +22,7 @@
 
 
+
 using namespace std;
-using namespace CHCDemo;
+using namespace CHCDemoEngine;
 
 
@@ -46,4 +47,7 @@
 int threshold;
 
+int assumedVisibleFrames = 10;
+int maxBatchSize = 50;
+bool useMultiQueries = true;
 
 const float keyForwardMotion = 1.0f;
@@ -58,5 +62,5 @@
 float visZoomFactor = 1.5f;
 
-long accumulatedTime = 1000;
+double accumulatedTime = 1000;
 float fps = 1e3f;
 
@@ -106,5 +110,4 @@
 void drawEyeView(void);
 void setupVisView(void);
-long calcRenderTime(void);
 void CalcDecimalPoint(std::string &str, int d);
 void ResetTraverser();
@@ -218,11 +221,4 @@
 		"",
 		"'F1'           - shows/dismisses this message",
-		"'F2'           - decreases number of objects (valid after scene recreation)",
-		"'F3'           - increases number of objects (valid after scene recreation)",
-		"'F4'           - decreases box length in z direction (valid after scene recreation)",
-		"'F5'           - increases box length in z direction (valid after scene recreation)",
-		"'F6'           - decreases object size (valid after scene recreation)",
-		"'F7'           - increases object size (valid after scene recreation)",
-		"'F8'           - cycles through object types (teapot, ...) (valid after scene recreation)",
 		"",
 		"'MOUSE-LEFT'   - turn left/right, move forward/backward",
@@ -235,11 +231,13 @@
 		"",
 		"'SPACE'        - cycles through occlusion culling algorithms",
-		"'-'            - decreases visibility threshold",
-		"'+'            - increases visibility threshold",
-		"'C'            - recreates the scene hierarchy",
+		"'-'            - decreases max batch size",
+		"'+'            - increases max batch size",
+		"'6'            - decrease assumed visible frames",
+		"'7'            - increase assumed visible frames",
+		"'8'            - upward motion",
+		"'9'            - downward motion",
+		"",
 		"'G'            - enables/disables optimization to take geometry as occluder",
-		"'N'            - triggers NV / ARB queries",
 		"",
-		"'R'            - shows/hides recreation parameters",
 		"'S'            - shows/hides statistics",
 		"'V'            - shows/hides bounding volumes",
@@ -312,4 +310,7 @@
 	traverser->SetUseRenderQueue(useRenderQueue);
 	traverser->SetVisibilityThreshold(threshold);
+	traverser->SetAssumedVisibleFrames(assumedVisibleFrames);
+	traverser->SetMaxBatchSize(maxBatchSize);
+	traverser->SetUseMultiQueries(useMultiQueries);
 }
 
@@ -430,11 +431,25 @@
 		break;
 	case '+':
-		threshold += 10;
-		traverser->SetVisibilityThreshold(threshold);
+		maxBatchSize += 10;
+		traverser->SetMaxBatchSize(maxBatchSize);
 		break;
 	case '-':
-		threshold -= 10;
-		if(threshold < 0) threshold = 0;
-		traverser->SetVisibilityThreshold(threshold);		
+		maxBatchSize -= 10;
+		if (maxBatchSize < 0) maxBatchSize = 1;
+		traverser->SetMaxBatchSize(maxBatchSize);		
+		break;
+	case '6':
+		assumedVisibleFrames -= 1;
+		if (assumedVisibleFrames < 1) assumedVisibleFrames = 1;
+		traverser->SetAssumedVisibleFrames(assumedVisibleFrames);
+		break;
+	case '7':
+		assumedVisibleFrames += 1;
+		traverser->SetAssumedVisibleFrames(assumedVisibleFrames);		
+		break;
+	case 'M':
+	case 'm':
+		useMultiQueries = !useMultiQueries;
+		traverser->SetUseMultiQueries(useMultiQueries);
 		break;
 	case '1':
@@ -852,5 +867,5 @@
 				    "CHC", "CHC ++"};
 
-	char msg2[200];
+	char msg2[400];
 	char msg3[200];
 	char msg4[200];
@@ -858,13 +873,11 @@
 
 
-	char *optstr[2] = {"", ", using optimization"};
-	
-	static long renderTime = traverser->GetStats().mRenderTime;
-	const float expFactor = 0.95f;
+	static double renderTime = traverser->GetStats().mRenderTime;
+	const float expFactor = 0.3f;
 	renderTime = traverser->GetStats().mRenderTime * expFactor + (1.0f - expFactor) * renderTime;
 
 	accumulatedTime += renderTime;
 
-	if (accumulatedTime > 100) // update every fraction of a second
+	if (accumulatedTime > 500) // update every fraction of a second
 	{	
 		accumulatedTime = 0;
@@ -882,5 +895,5 @@
 	}
 
-	sprintf_s(msg2, "threshold: %4d%s", threshold, optstr[useOptimization]);
+	sprintf_s(msg2, "assumed visible frames: %4d, max batch size: %4d, using multiqueries: %d, using render queue: %d", assumedVisibleFrames, maxBatchSize, useMultiQueries, useRenderQueue);
 
 	string str;
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/CHCPlusPlusTraverser.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/CHCPlusPlusTraverser.cpp	(revision 2774)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/CHCPlusPlusTraverser.cpp	(revision 2776)
@@ -4,5 +4,5 @@
 using namespace std;
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
@@ -18,29 +18,59 @@
 	const int visible = query->GetQueryResult() > mVisibilityThreshold;
 
-	BvhNode *node = query->GetFrontNode();
-
-	if (visible)
-	{
-		// node was previously invisible
-		if (!node->IsVisible())
-		{
-			// reset flag
-			node->SetTimesTestedInvisible(0);
-			node->SetAssumedVisibleFrameId(mFrameId + mAssumedVisibleFrames);
+	// multiquery
+	if (query->GetSize() > 1)
+	{
+		// failed query: query individual nodes
+		if (visible)
+		{
+			for (size_t i = 0; i < query->GetSize(); ++ i)
+			{
+				BvhNode *node = query->GetNodes()[i];
+				OcclusionQuery *q = IssueOcclusionQuery(node, false);
+				mQueryQueue.push(q);
+			}
+		}
+		else // query successful: update classifications
+		{
+			for (size_t i = 0; i < query->GetSize(); ++ i)
+			{
+				BvhNode *node = query->GetNodes()[i];
+				node->IncTimesTestedInvisible();
+				node->SetVisible(false);
+			}
+
+			mStats.mNumQueryCulledNodes += query->GetSize();
+		}
+	}
+	else // single query
+	{
+		BvhNode *node = query->GetFrontNode();
+
+		// failed query: query individual nodes
+		if (visible)
+		{
+			// node was previously invisible
+			if (!node->IsVisible())
+			{
+				// reset flag
+				node->SetTimesTestedInvisible(0);
+				node->SetAssumedVisibleFrameId(mFrameId + mAssumedVisibleFrames);
+			}
+			else
+			{	// randomize first invokation
+				node->SetAssumedVisibleFrameId(mFrameId + Random(mAssumedVisibleFrames + 1));
+			}
+
+			mBvh->MakeParentsVisible(node);
+			TraverseNode(node);
 		}
 		else
-			// randomize first invokation
-			node->SetAssumedVisibleFrameId(mFrameId + Random(mAssumedVisibleFrames + 1));
-
-		mBvh->MakeParentsVisible(node);
-		TraverseNode(node);
-	}
-	else
-	{
-		node->IncTimesTestedInvisible();
-		++ mStats.mNumQueryCulledNodes;
-	}
-
-	node->SetVisible(visible);
+		{
+			node->IncTimesTestedInvisible();
+			++ mStats.mNumQueryCulledNodes;
+		}
+
+		node->SetVisible(visible);
+	}
 }
 
@@ -51,5 +81,5 @@
 	while (!mDistanceQueue.empty() || !mQueryQueue.empty())
 	{
-		bool resultAvailable;
+		bool resultAvailable = false;
 		while (!mQueryQueue.empty() && 
 			   (mDistanceQueue.empty() || (resultAvailable = mQueryQueue.front()->ResultAvailable())))
@@ -119,4 +149,16 @@
 						}
 					}
+					else
+					{
+						if (node->IsVirtualLeaf())
+						{
+							node->SetVisible(true);
+							mBvh->MakeParentsVisible(node);
+						} 
+						else // reset visibility classification
+						{
+							node->SetVisible(false);
+						}
+					}
 					
 					// always traverse a node if it was previously visible
@@ -202,4 +244,5 @@
 		if (query->GetNodes().empty())
 		{
+			// single node will anever cause a wasted query
 			newBatchVal = 1.0f;
 		}
@@ -219,4 +262,5 @@
 	}
 
+	//cout <<"size: " << query->GetSize() << endl;
 	IssueOcclusionQuery(*query, false);
 
@@ -227,20 +271,18 @@
 void CHCPlusPlusTraverser::IssueMultiQueries()
 {
-	if (0 && mUseRenderQueue)
-	{
-		if (mRenderState->SetState(RenderState::RENDER))
-			++ mStats.mNumStateChanges;
-	
-		mRenderQueue.Render();
-		mRenderQueue.Clear();
-	}
-
 	while (!mIQueue.empty())
 	{
-		BvhNode *node = mIQueue.front();
-		mIQueue.pop();
-
-		OcclusionQuery *query = GetNextMultiQuery(mIQueue);
-		//OcclusionQuery *query = IssueOcclusionQuery(node);
+		OcclusionQuery *query;
+
+		if (mUseMultiQueries)
+		{
+			query = GetNextMultiQuery(mIQueue);
+		}
+		else
+		{
+			BvhNode *node = mIQueue.front();
+			mIQueue.pop();
+			query = IssueOcclusionQuery(node, false);
+		}
 
 		mQueryQueue.push(query);
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/Matrix4x4.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/Matrix4x4.cpp	(revision 2752)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/Matrix4x4.cpp	(revision 2776)
@@ -6,5 +6,5 @@
 using namespace std;
 
-namespace CHCDemo 
+namespace CHCDemoEngine 
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/BinaryLoader.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/BinaryLoader.cpp	(revision 2769)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/BinaryLoader.cpp	(revision 2776)
@@ -11,5 +11,5 @@
 
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/FrustumCullingTraverser.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/FrustumCullingTraverser.cpp	(revision 2771)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/FrustumCullingTraverser.cpp	(revision 2776)
@@ -5,5 +5,5 @@
 
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/RenderTraverser.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/RenderTraverser.h	(revision 2773)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/RenderTraverser.h	(revision 2776)
@@ -10,5 +10,5 @@
 
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
@@ -39,5 +39,5 @@
 	int mNumPreviouslyVisibleNodeQueries;
 	
-	long mRenderTime;
+	double mRenderTime;
 };
 
@@ -106,5 +106,7 @@
 	*/
 	void SetMaxBatchSize(int batchSize);
-
+	/** If multiqueries should be used.
+	*/
+	void SetUseMultiQueries(bool useMultiQueries);
 
 protected:
@@ -167,4 +169,6 @@
 
 	int mMaxBatchSize;
+
+	bool mUseMultiQueries;
 };
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/AxisAlignedBox3.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/AxisAlignedBox3.cpp	(revision 2762)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/AxisAlignedBox3.cpp	(revision 2776)
@@ -8,5 +8,5 @@
 
 
-namespace CHCDemo
+namespace CHCDemoEngine
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/Camera.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/Camera.cpp	(revision 2764)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/Camera.cpp	(revision 2776)
@@ -4,5 +4,5 @@
 
 
-namespace CHCDemo 
+namespace CHCDemoEngine 
 {
 
Index: /GTP/trunk/App/Demos/Vis/CHC_revisited/common.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/CHC_revisited/common.h	(revision 2770)
+++ /GTP/trunk/App/Demos/Vis/CHC_revisited/common.h	(revision 2776)
@@ -18,5 +18,5 @@
 
 
-namespace CHCDemo 
+namespace CHCDemoEngine 
 {
 
