Index: branches/terrain/src/lib/graphics/importer/terrain/terrain.cc
===================================================================
--- branches/terrain/src/lib/graphics/importer/terrain/terrain.cc	(revision 8715)
+++ branches/terrain/src/lib/graphics/importer/terrain/terrain.cc	(revision 8741)
@@ -29,20 +29,15 @@
 	memcpy( heightfield.data, tmpData->pixels, sizeof(UByte)*dataSize );
 	SDL_FreeSurface( tmpData );
-	//TODO: Perform some checks...
+	//TODO: Perform some checks... size, bits and so on
 	pagesX = (heightfield.width/(pageSize-1) );
 	pagesZ = (heightfield.height/(pageSize-1) );
-	//tex = (Texture*)MANAGER->load( lightmapSource );
 	//TODO: Determine layer visibility!	
 	for ( unsigned int i = 0; i < materials.size(); ++i ) {
 		
 	}
-
-	printf( " * creating terrain pages ( %d, %d )...", pagesX, pagesZ );
 	pages = new pTerrainPage[pagesX*pagesZ];	
 	for ( int x = 0; x < pagesX; ++x )
 		for ( int z = 0; z < pagesZ; ++z )
 			pages[z*pagesX+x] = createPage( x, z );
-	printf( "looks good\n" );
-	printf( " * inform pages about the adjacent pages..." );			
 	//Inform each page about its neighbors.
 	for ( int x = 0; x < pagesX; ++x )
@@ -54,9 +49,6 @@
 				z > 0 			? getPage( x+0, z-1 ) : NULL );
 	
-	printf( "looks good\n" );
-	printf( " * creating quad_tree data structure..." );
 	root = createQuadTree( 0, 0, pagesX, pagesZ );
 	activePages = NULL;
-	printf( "looks good\n" );
 }
 
@@ -104,5 +96,4 @@
 		glBufferDataARB( GL_ELEMENT_ARRAY_BUFFER_ARB, MAX_INDICES*sizeof( short ), 
 			indices, GL_DYNAMIC_DRAW_ARB );
-		//printf( "uploaded %d verts and %d indices\n", bi.numIndices, bi.numVertices );
 		BufferInfo newInfo;
 		broker->acquire( newInfo.vbIdentifier, newInfo.ibIdentifier );			
@@ -114,17 +105,19 @@
 	memcpy( &vertices[bi.numVertices], _vertices, 
 		_numVertices*sizeof( Vertex ) );
-	bi.numVertices+=_numVertices;
 	//The indices need to be updated with an offset :(
-	unsigned short *end = _indices+_numIndices;
-	unsigned short *dst = indices+bi.numIndices;
-	int offset = bi.numIndices;
-	if ( bi.numIndices > 0 ) {
-		indices[bi.numIndices] = indices[bi.numIndices-1];
-		indices[bi.numIndices+1] = _indices[0]+offset;
-		dst+=2;
-		bi.numIndices+=2;
-	}
-	for ( unsigned short *i = _indices; i < end; ++i, ++dst ) {
-		*dst = *i+offset;
+	unsigned short *dst= &indices[bi.numIndices];
+	unsigned short offset = bi.numVertices;
+	unsigned short *src= _indices;
+	unsigned short *end= src+_numIndices;
+	bi.numVertices+=_numVertices;		
+	if ( bi.numIndices ) {
+		dst[0] = *(dst-1);
+		dst[1] = *src+offset;
+		dst+=2; bi.numIndices+=2;
+	}
+	while ( src < end ) {
+		*dst= *src+offset;
+		dst++;
+		src++;
 	}
 	bi.numIndices+=_numIndices;
@@ -167,5 +160,5 @@
 	frustum->extractPlanes();
 	
-	/**
+	/*
 	 * Enable texture and vertex arrays for the first and the second texture
 	 * units and disable the normal arrays.
@@ -181,4 +174,5 @@
 		glDisableClientState( GL_NORMAL_ARRAY ); 
 	glDisable( GL_CULL_FACE );
+	glCullFace( GL_BACK );
 	glDisable( GL_LIGHTING );
 	glColor3f( 1.0f, 1.0f, 1.0f );
@@ -230,4 +224,5 @@
 	page = activePages;
 	while ( page ) {
+		assert( page->isActive() );
 		page->updateTesselation();
 		page = page->getNext();
@@ -236,14 +231,11 @@
 	if ( buffers[current].numIndices != 0 ) {
 		BufferInfo bi = buffers[current];	
-		glBindBufferARB( GL_ARRAY_BUFFER_ARB, 
-			bi.vbIdentifier );
+		glBindBufferARB( GL_ARRAY_BUFFER_ARB, bi.vbIdentifier );
 		glBufferDataARB( GL_ARRAY_BUFFER_ARB, MAX_VERTICES*sizeof( Vertex ), 
 			vertices, GL_DYNAMIC_DRAW_ARB );
-		glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 
-			bi.ibIdentifier );
+		glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, bi.ibIdentifier );
 		glBufferDataARB( GL_ELEMENT_ARRAY_BUFFER_ARB, MAX_INDICES*sizeof( short ), 
 			indices, GL_DYNAMIC_DRAW_ARB );
 	}
-	s = 200.0f;
 	glPushAttrib( GL_COLOR_BUFFER_BIT );
 	for ( unsigned int i = 0; i < materials.size(); ++i ) {
@@ -258,5 +250,5 @@
 		glMatrixMode( GL_TEXTURE );
 		glLoadIdentity();
-		glScalef( s, s, s );
+		glScalef( pagesX, pagesZ, 1.0f );
 
 		glClientActiveTextureARB( GL_TEXTURE0_ARB );
@@ -264,4 +256,5 @@
 		glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );				
 		glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
+		glEnable( GL_CULL_FACE );
 		for ( unsigned j = 0; j < buffers.size(); ++j ) {
 			BufferInfo bi = buffers[j];
Index: branches/terrain/src/lib/graphics/importer/terrain/terrain.h
===================================================================
--- branches/terrain/src/lib/graphics/importer/terrain/terrain.h	(revision 8715)
+++ branches/terrain/src/lib/graphics/importer/terrain/terrain.h	(revision 8741)
@@ -76,5 +76,5 @@
 		 * reasonable value...
 		 */
-		inline float getDetail() { return 0.05f; }
+		inline float getDetail() { return 0.02f; }
 
 	
Index: branches/terrain/src/lib/graphics/importer/terrain/terrain_page.cc
===================================================================
--- branches/terrain/src/lib/graphics/importer/terrain/terrain_page.cc	(revision 8715)
+++ branches/terrain/src/lib/graphics/importer/terrain/terrain_page.cc	(revision 8741)
@@ -44,5 +44,6 @@
 }
 
-void TerrainPage::tesselateRow( int _z, int _xStride, int _zStride, bool _adaptLeft, bool _adaptRight )
+void TerrainPage::tesselateRow( int _z, int _xStride, int _zStride, 
+	bool _adaptLeft, bool _adaptRight )
 {
 	
@@ -51,5 +52,5 @@
 	assert( _xStride > 0 ); 	assert( _zStride > 0 );
 	if ( _z ) {
-		addAgain( );
+		addAgain();
 		addIndex( getIndex( 0, _z ) );
 	}
@@ -77,8 +78,8 @@
 	if ( _adaptRight ) {
 		assert( halfStride > 0 ); 		
-		addIndex( getIndex( w-_xStride, _z ) );
+		addIndex( getIndex( xEnd-1, _z ) );
 		addAgain();
 		addIndex( getIndex( w, _z ) );
-		addIndex( getIndex( w-_xStride, _z+_zStride ) );
+		addIndex( getIndex( xEnd-1, _z+_zStride ) );
 		addIndex( getIndex( w, _z+halfStride ) );
 		addIndex( getIndex( w, _z+_zStride ) );
@@ -92,15 +93,21 @@
 	_adapt[0] = _adapt[1] = _adapt[2] = _adapt[3] = false;
 	
-	if ( left  && left->isVisible ) 
+	if ( left  && left->isActive() ) {
 		_adapt[TP_LEFT] = ( wantedLOD - left->getWantedLOD() ) > 0;
-		
-	if ( right && right->isVisible ) 
+		assert( std::abs( wantedLOD - left->wantedLOD ) < 2 );		
+	}	
+	if ( right && right->isActive() ) {
 		_adapt[TP_RIGHT] = ( wantedLOD - right->getWantedLOD() ) > 0;
-		
-	if ( top && top->isVisible ) 
+		assert( std::abs( wantedLOD - right->wantedLOD ) < 2 );		
+	}	
+		
+	if ( top && top->isActive() ) {
 		_adapt[TP_TOP] = ( wantedLOD - top->getWantedLOD() ) > 0;				
-		
-	if ( bottom && bottom->isVisible ) 
+		assert( std::abs( wantedLOD - top->wantedLOD ) < 2 );		
+	}	
+	if ( bottom && bottom->isActive() ) {
 		_adapt[TP_BOTTOM] = ( wantedLOD - bottom->getWantedLOD() ) > 0;		
+		assert( std::abs( wantedLOD - bottom->wantedLOD ) < 2 );
+	}	
 }
 
@@ -246,5 +253,6 @@
 			iChanged		=  wantedLOD != currentLOD;
 				
-	return ( leftChanged || rightChanged || topChanged || bottomChanged || forceTesselation || iChanged );
+	return ( leftChanged || rightChanged || topChanged || bottomChanged || 
+		forceTesselation || iChanged );
 }
 
@@ -256,6 +264,7 @@
 	}	
 	currentLOD = wantedLOD;
+	
 	//Check if the page is a level four page. If yes, copy the vertex and index data into 
-	//
+	//the shared level four page buffers.
 	if ( currentLOD == TerrainPage::MAX_LODS-1 ) {
 		owner->addLevelFourPage( numVertices, vertices, 
@@ -263,4 +272,92 @@
 	}
 	forceTesselation = false;
+}
+
+void TerrainPage::tesselateTopRow(  int _z, int _stride, 
+	bool _adaptLeft,  bool _adaptRight )
+{
+	int halfStride = _stride/2;
+	int xStart = 0, xEnd= owner->getPageSize()-1;
+	int size = xEnd;
+	int z = xEnd-_stride ;	
+	addAgain();
+	addIndex( getIndex( 0, z ) );
+	assert(halfStride>=1);
+
+	if( _adaptLeft ) {
+		addIndex( getIndex( 0, z ) );
+		addIndex( getIndex( 0, z+halfStride ) );
+		addIndex( getIndex( _stride, z ) );
+		addIndex( getIndex( 0, size ) );
+		addIndex( getIndex( halfStride, size ) );
+		addAgain();
+		addIndex( getIndex( _stride, z ) );
+		addIndex( getIndex( _stride, size ) );
+		xStart = _stride;
+	}
+
+	if ( _adaptRight )
+		xEnd -= _stride;
+	for ( int x = xStart; x < xEnd; x+=_stride ) {
+		addIndex( getIndex( x, z ) );
+		addIndex( getIndex( x, size ) );
+		addIndex( getIndex( x+_stride, z ) );
+		addIndex( getIndex( x+halfStride, size ) );
+		addIndex( getIndex( x+_stride, size ) );
+		addAgain();
+	}
+
+	if ( _adaptRight ) {
+		addIndex( getIndex( xEnd, z ) );
+		addIndex( getIndex( xEnd, size ) );
+		addIndex( getIndex( size, z ) );
+		addIndex( getIndex( xEnd+halfStride, size ) );
+		addIndex( getIndex( size, size-halfStride ) );
+		addIndex( getIndex( size, size ) );
+	}
+
+}
+void TerrainPage::tesselateBottomRow(  int _z,  int _stride,  
+	bool _adaptLeft,  bool _adaptRight  )
+{
+	int halfStride = _stride/2;
+	int xStart=0, xEnd=owner->getPageSize()-1;
+	int size = xEnd;
+	assert( halfStride>=1 );
+
+	if ( _adaptLeft ) {
+		addIndex( getIndex( 0, 0 ) );
+		addIndex( getIndex( 0, halfStride ) );
+		addIndex( getIndex( halfStride, 0 ) );
+		addIndex( getIndex( 0, _stride ) );
+		addIndex( getIndex( _stride, 0 ) );
+		addIndex( getIndex( _stride, _stride ) );
+		xStart = _stride;
+	}
+
+
+	if ( _adaptRight )
+		xEnd -= _stride;
+
+	for ( int x = xStart; x < xEnd; x+=_stride ) {
+		addIndex( getIndex( x, 0 ) );
+		addAgain();
+		addIndex( getIndex( x+halfStride, 0 ) );
+		addIndex( getIndex( x, _stride ) );
+		addIndex( getIndex( x+_stride ,0 ) );
+		addIndex( getIndex( x+_stride, _stride ) );
+	}
+
+
+	if( _adaptRight ) {
+		addIndex( getIndex( xEnd,0 ) );
+		addIndex( getIndex( xEnd,_stride ) );
+		addIndex( getIndex( xEnd+halfStride, 0 ) );
+		addIndex( getIndex( size ,0 ) );
+		addAgain();
+		addIndex( getIndex( xEnd, _stride ) );
+		addIndex( getIndex( size, halfStride ) );
+		addIndex( getIndex( size, _stride ) );
+	}
 }
 
@@ -294,5 +391,5 @@
 			addIndex( getIndex( 0, stride ) );
 			addIndex( getIndex( stride, stride ) );
-			addAgain(  );
+			addAgain( );
 		 	break;
 		
@@ -303,5 +400,5 @@
 			addIndex( getIndex( stride, 0 ) );
 			addIndex( getIndex( 0, 0 ) );
-			addAgain(  );
+			addAgain( );
 			break;
 
@@ -317,5 +414,5 @@
 		case ADAPT_B:
 			addIndex( getIndex( 0, 0 ) );
-			addAgain(  );
+			addAgain();
 			addIndex( getIndex( halfStride, 0 ) );
 			addIndex( getIndex( 0, stride ) );
@@ -513,5 +610,5 @@
 	
 	if ( adapt[TP_BOTTOM] ) {
-		tesselateRow( 0, stride / 2, stride, adapt[TP_LEFT], adapt[TP_RIGHT] );
+		tesselateBottomRow( 0, stride, adapt[TP_LEFT], adapt[TP_RIGHT] );
 		zStart+= stride;
 	}
@@ -525,7 +622,5 @@
 
 	if ( adapt[TP_TOP] ) {
-		addAgain( );
-		addIndex( getIndex( 0, owner->getPageSize()-1-stride ) );
-		tesselateRow( owner->getPageSize()-1-stride, stride / 2, 
+		tesselateTopRow( owner->getPageSize()-stride-1, 
 			stride, adapt[TP_LEFT], adapt[TP_RIGHT] );
 	}
@@ -621,5 +716,4 @@
 	active = false;
 	CHECK_GL_ERROR( "1" );	
-	
 #ifdef USE_VBO
 	
Index: branches/terrain/src/lib/graphics/importer/terrain/terrain_page.h
===================================================================
--- branches/terrain/src/lib/graphics/importer/terrain/terrain_page.h	(revision 8715)
+++ branches/terrain/src/lib/graphics/importer/terrain/terrain_page.h	(revision 8741)
@@ -233,5 +233,6 @@
 		 */
 		void tesselateRow( int _z, int _xStride, int _zStride, bool _adaptLeft, bool _adaptRight );
-
+		void tesselateTopRow( int _z, int _stride, bool _adaptLeft, bool _adaptRight );
+		void tesselateBottomRow( int _z, int _stride, bool _adaptLeft, bool _adaptRight );
 		/** 
 		 * @brief Returns four boolean values in the oder
