 		private function cascadeWindows():void
 		{
 			var panels:Array = getWindowsOnStage();
-			if(!panels.length) return;
-			
-			var dpanel:DraggablePanel;
-			dpanel = panels[panels.length-1] as DraggablePanel;
-			
-			dpanel.panelWidth.value = "50%";
-			dpanel.panelHeight.value = "50%";
+			if(!panels.length) return;			
 			
 			var increment:Number = 50/panels.length;
 			var dist:Number = 0 ;
 			
-			for( var i:int = 0; i < panels.length ; i++ ) 
-			{
-				dpanel = panels[i] as DraggablePanel;
-				dpanel.panelX.value = dist.toString()+"%";
-				dpanel.panelY.value = dist.toString()+"%";
-				dpanel.panelWidth.value = "50%" ;
-				dpanel.panelHeight.value = "50%" ;
+			for each( var dp:DraggablePanel in panels)
+			{				
+				dp.panelX.value = dp.panelY.value = dist.toString()+"%";			
+				dp.panelHeight.value = dp.panelWidth.value = "50%" ;	
+				
 				dist += increment;
 			}
 		}

				
			// Minimize All Windows: Get a list of all panels and call minimizePanel() on each sequentially
			click = function():void {
				var children:Array = Weave.root.getObjects(DraggablePanel);
				while (children.length)
				{
					var panel:DraggablePanel = children.pop() as DraggablePanel;
					if(panel.minimizable.value) panel.minimizePanel();
				}
			};

			if(!numPanels) return;
			
			var gridLength:Number = Math.ceil(Math.sqrt(numPanels));
			
			var rows:uint = gridLength; 
			var columns:uint = gridLength;
			
			if(gridLength*gridLength != numPanels)
			{	
				rows = Math.round(Math.sqrt(numPanels));
				columns = gridLength;
			}			
						
			var xPos:Number = 0;
			var yPos:Number = 0 ;
			var width:Number = 100/((stage.stageWidth > stage.stageHeight) ? rows : columns);
			var height:Number = 100/((stage.stageWidth > stage.stageHeight) ? columns : rows);
			
			var i:int = 0;
			for each( var dp:DraggablePanel in panels)
			{				
				dp.panelX.value = xPos.toString() + "%";
				dp.panelY.value = yPos.toString() + "%";
				
				dp.panelHeight.value = height.toString() + "%";
				dp.panelWidth.value = width.toString() + "%";
				if( i == (panels.length - 1))
				{
					// expand to fill the width of stage
					dp.panelWidth.value = (100-xPos).toString() + "%";
				}
				
				xPos += width;
				if(xPos >= 100) xPos = 0;
				if( !xPos) yPos += height ;
				i++;
			}
		}
		
		/**
		 * @author kmanohar
		 * @return an Array containing all DraggablePanels on stage that are not minimized
		 */		
		private function getWindowsOnStage():Array
		{
			var panels:Array = Weave.root.getObjects(DraggablePanel);
			var panelsOnStage:Array = [];
			
			for each( var panel:DraggablePanel in panels )
			{				
				if(!panel.minimized.value) 
					panelsOnStage.push(panel);
			}
			return panelsOnStage;
		}
