diff --git a/Core/SetContainer.lhs b/Core/SetContainer.lhs
--- a/Core/SetContainer.lhs
+++ b/Core/SetContainer.lhs
@@ -20,8 +20,8 @@
 >     type SetContainerElem c   
 > 
 >     empty        :: c                
->     components   :: c -> [Component (SetContainerElem c)]
 >     insert       :: SetContainerElem c -> c -> c     
+>     components   :: c -> [Component (SetContainerElem c)]
 >     relatedElems :: SetContainerElem c -> c -> [(SetContainerElem c, c)] 
 
 > data Component e
diff --git a/GTK.hs b/GTK.hs
--- a/GTK.hs
+++ b/GTK.hs
@@ -19,6 +19,8 @@
 import Graphics.Rendering.Cairo (liftIO)        -- ???
 
 import Data.Time.Clock
+import qualified Data.Function
+import Data.List (sortBy)
 import Control.Monad (when)
 import Control.Concurrent
 
@@ -217,13 +219,44 @@
     backgroundColor <- styleGetBackground style StateNormal
     (width, height) <- drawableGetSize win
     let ss =  (fromIntegral width / fromIntegral (xSize s), fromIntegral height / fromIntegral (ySize s))
-    mapM_ (drawSquare win (backgroundColor, blue, green, dangerColor, black, white, between 0.5 black blue, color 1 0.9 0.7) ss) l
+    let gs = groupSquares [(coords p, ss) | (p, ss) <- l]
+--    putStrLn $ show (sum $ map (\(_,_,x)->length x) gs) ++ " sqares " ++ show (length gs) ++ " groups"
+    mapM_ (drawSquare win (backgroundColor, blue, green, dangerColor, black, white, between 0.5 black blue, color 1 0.9 0.7) ss) $ gs
 
+joinBy p (a: b: xs) = case p a b of
+    Just c  -> joinBy p (c: xs)
+    Nothing -> a: joinBy p (b: xs)
+joinBy _ xs = xs
 
-drawSquare win style (a, b) (p, xx) = do
-    let (x, y) = coords p
-    drawWindowBeginPaintRect win $ Rectangle (round $ a*fromIntegral (x-1)) (round $ b*fromIntegral (y-1)) (ceiling a) (ceiling b)
-    renderWithDrawable win $ renderSquare style (a, b) (x, y) xx
+groupSquares :: [((Int, Int), SquareState)] -> [((Int,Int), (Int,Int), [((Int,Int), SquareState)])]
+groupSquares = joinBy col . joinBy row . map init . joinBy eqq . sortBy (compare `Data.Function.on` fst) where
+
+    init (p, ss) = (p, (1,1), [(p, ss)])
+
+    eqq ((x1,y1),xs1) ((x2,y2),_)
+        | y1 == y2 && x1 == x2
+        = Just ((x1,y1),xs1)
+    eqq _ _ = Nothing
+
+    col ((x1,y1),(w1,h1),xs1) ((x2,y2),(w2,h2),xs2)
+        | y1 == y2 && h1 == h2 && x2 == x1 + w1
+        = Just ((x1,y1),(w1 + w2, h1),xs1 ++ xs2)
+--        | y1 == y2 && h1 == h2 && x1 == x2 + w2
+--        = Just ((x2,y1),(w1 + w2, h1),xs1 ++ xs2)
+    col _ _ = Nothing
+
+    row ((x1,y1),(w1,h1),xs1) ((x2,y2),(w2,h2),xs2)
+        | x1 == x2 && w1 == w2 && y2 == y1 + h1
+        = Just ((x1,y1),(w1, h1 + h2),xs1 ++ xs2)
+--        | x1 == x2 && w1 == w2 && y1 == y2 + h1
+--        = Just ((x1,y2),(w1, h1 + h2),xs1 ++ xs2)
+    row _ _ = Nothing
+
+drawSquare win style (a, b) ((x,y),(w,h), xx) = do
+    drawWindowBeginPaintRect win $
+        Rectangle (round $ a*fromIntegral (x-1)) (round $ b*fromIntegral (y-1))
+                  (ceiling $ a * fromIntegral w) (ceiling $ b * fromIntegral h)
+    renderWithDrawable win $ mapM_ (uncurry $ renderSquare style (a, b)) xx
     drawWindowEndPaint win
 
 ------------------------
diff --git a/GTK/Square.hs b/GTK/Square.hs
--- a/GTK/Square.hs
+++ b/GTK/Square.hs
@@ -12,10 +12,15 @@
 
 -----------------------------------------
 
+saveAndRestore m = do
+    save
+    _ <- m
+    restore
+
 renderSquare :: (Color, Color, Color, Int -> Color, Color, Color, Color, Color) ->
     (Double, Double) -> (Int, Int) -> SquareState -> Render ()
 renderSquare (background, activeColor, prelightColor, dangerColor, black, white, darkblue, yellow) 
-    (a, b) (x, y) squareState = do
+    (a, b) (x, y) squareState = saveAndRestore $ do
 
     scale a b
     translate (fromIntegral x - 0.5) (fromIntegral y - 0.5)
diff --git a/minesweeper.cabal b/minesweeper.cabal
--- a/minesweeper.cabal
+++ b/minesweeper.cabal
@@ -1,5 +1,5 @@
 name:                minesweeper
-version:             0.9.2
+version:             0.9.2.1
 category:            Game
 synopsis:            Minesweeper game which is always solvable without guessing
 description:
@@ -35,14 +35,14 @@
     CPP
 
   build-depends:
-    base >= 3 && < 4.7,
+    base >= 3 && < 4.8,
     containers >= 0.3 && < 0.6,
     time >= 1.2 && < 1.5,
     random >= 1.0 && < 1.1,
  --    mersenne-random-pure64 == 0.2.*,
     directory >= 1.0 && < 1.3,
     filepath >= 1.1 && < 1.4,
-    binary >= 0.5 && < 0.7,
+    binary >= 0.5 && < 0.8,
     binary-generic >= 0.2 && < 0.3,
     bytestring >= 0.9 && < 0.11,
     gtk >= 0.11 && < 0.13,
