--- Controller.m	2011-06-16 10:35:03.000000000 +0200
+++ /home/multix/Desktop/Controller.m	2011-06-16 10:38:09.000000000 +0200
@@ -42,9 +42,11 @@
 
 + (NSPanel *)prog_ind
 {
-    if(_prog_ind_panel==nil){
+    if(_prog_ind_panel==nil)
+      {
 	NSRect pi_frame =
 	    NSMakeRect(0, 0, PROG_IND_WIDTH, PROG_IND_HEIGHT);
+	KnobView *_prog_ind;
 
         _prog_ind_panel = 
             [[NSPanel alloc]
@@ -54,8 +56,7 @@
                 defer:NO];
         [_prog_ind_panel setReleasedWhenClosed:NO];
         
-	KnobView *_prog_ind =
-	    [[KnobView alloc] initWithFrame:pi_frame];
+	_prog_ind = [[KnobView alloc] initWithFrame:pi_frame];
         [_prog_ind_panel setContentView:_prog_ind];
 
 	[_prog_ind_panel setTitle:_(@"Computing Sudoku")];
@@ -184,12 +188,14 @@
 - makeInputPanel
 {
   int m = NSTitledWindowMask;
-
-  NSRect frame = 
-      {{ 0, BUTTON_HEIGHT + DIGIT_FIELD_DIM},  { SDK_DIM, SDK_DIM} };
+  int x;
+  float margin;
+  NSButton *button;
+  NSRect allframe ;
+  NSRect frame = {{ 0, BUTTON_HEIGHT + DIGIT_FIELD_DIM},  { SDK_DIM, SDK_DIM} };
   sdkview  = [[SudokuView alloc] initWithFrame:frame];
 
-  NSRect allframe = frame;
+  allframe = frame;
   allframe.size.height += BUTTON_HEIGHT + DIGIT_FIELD_DIM;
 
   enterPanel = 
@@ -202,10 +208,9 @@
 
   [[enterPanel contentView] addSubview:sdkview];
 
-  float margin = (SDK_DIM - DIGIT_FIELD_DIM*10)/2;
+  margin = (SDK_DIM - DIGIT_FIELD_DIM*10)/2;
   assert(margin>0);
 
-  int x;
   for(x=1; x<=10; x++){
       DigitSource *dgs =
 	[[DigitSource alloc] 
@@ -216,13 +221,12 @@
   }
 
 
-  NSButton *button = [NSButton new];
+  button = [NSButton new];
   [button setTitle:_(@"Enter")];
   [button setTarget:self];
   [button setAction:@selector(actionEnter:)];
 
-  [button 
-      setFrame:NSMakeRect(0, 0, SDK_DIM/3, BUTTON_HEIGHT)];
+  [button setFrame:NSMakeRect(0, 0, SDK_DIM/3, BUTTON_HEIGHT)];
   
   [[enterPanel contentView] addSubview:button];
 
@@ -231,8 +235,7 @@
   [button setTarget:self];
   [button setAction:@selector(actionReset:)];
 
-  [button 
-      setFrame:NSMakeRect(SDK_DIM/3, 0, SDK_DIM/3, BUTTON_HEIGHT)];
+  [button setFrame:NSMakeRect(SDK_DIM/3, 0, SDK_DIM/3, BUTTON_HEIGHT)];
   
   [[enterPanel contentView] addSubview:button];
 
@@ -241,8 +244,7 @@
   [button setTarget:self];
   [button setAction:@selector(actionCancel:)];
 
-  [button 
-      setFrame:NSMakeRect(2*SDK_DIM/3, 0, SDK_DIM/3, BUTTON_HEIGHT)];
+  [button setFrame:NSMakeRect(2*SDK_DIM/3, 0, SDK_DIM/3, BUTTON_HEIGHT)];
   
   [[enterPanel contentView] addSubview:button];
 
@@ -255,40 +257,50 @@
 
 - actionEnter:(id)sender
 {
-    [[NSApplication sharedApplication]
-        stopModal];
+  BOOL success;
+  NSDocumentController *dc;
+  Document *doc;
+  Sudoku *sdk;
+  Sudoku *user;
+  NSPanel *pi_panel;
+  KnobView *pi;
+  NSModalSession solveSession;
+  float percent, dir;
+  NSDate *end;
+
+    [[NSApplication sharedApplication] stopModal];
     [enterPanel orderOut:self];
 
     [palette orderFront:self];
 
-    NSApplication *app = [NSApplication sharedApplication];
-
-    NSDocumentController *dc =
-        [NSDocumentController sharedDocumentController];
+    dc = [NSDocumentController sharedDocumentController];
     [dc newDocument:self];
 
-    Document *doc = [dc currentDocument];
-    Sudoku *sdk = [doc sudoku], *user = [sdkview sudoku];
+    doc = [dc currentDocument];
+    sdk = [doc sudoku];
+    user = [sdkview sudoku];
 
     [sdk copyStateFromSource:user];
     [sdk guessToClues];
     // [sdk cluesToPuzzle];
 
-    NSPanel *pi_panel = [Controller prog_ind];
-    KnobView *pi = [pi_panel contentView];
+    pi_panel = [Controller prog_ind];
+    pi = [pi_panel contentView];
     
     [pi_panel makeKeyAndOrderFront:self];
 
-    NSModalSession solveSession;
-    solveSession = [app beginModalSessionForWindow:pi_panel];
+    solveSession = [[NSApplication sharedApplication] beginModalSessionForWindow:pi_panel];
 
-    float percent = 0, dir = 1;
+    percent = 0;
+    dir = 1;
 
-    BOOL success;
-    NSDate *end = [NSDate dateWithTimeIntervalSinceNow:MAX_SOLVE_SECS];
+    end = [NSDate dateWithTimeIntervalSinceNow:MAX_SOLVE_SECS];
 
+    success = NO;
     do {
 	int tick;
+	NSDate *now;
+
 	for(tick=0; tick<TICK_ITER; tick++){
 	    [pi setPercent:percent];
 	    [pi display];
@@ -305,9 +317,9 @@
 	    dir = +1;
 	}
 
-	[app runModalSession:solveSession];
+	[[NSApplication sharedApplication] runModalSession:solveSession];
 
-	NSDate *now = [NSDate date];
+	now = [NSDate date];
 	if([now laterDate:end]==now){
 	    break;
 	}
@@ -316,7 +328,7 @@
     } while(success==NO);
 
     [pi_panel orderOut:self];
-    [app endModalSession:solveSession];
+    [[NSApplication sharedApplication] endModalSession:solveSession];
 
     if(success==NO){
 	NSRunAlertPanel(_(@"Solve failed"),
@@ -401,6 +413,7 @@
 
 - makeDigitPalette
 {
+  int x, y;
   NSRect pbounds = 
     NSMakeRect(0, 0, 2*DIGIT_FIELD_DIM, 5*DIGIT_FIELD_DIM);
 
@@ -425,7 +438,6 @@
   [palette setFrameAutosaveName: @"SudokuDigitPalette"];
 
 
-  int x, y;
   for(x=0; x<2; x++){
     for(y=0; y<5; y++){
       DigitSource *dgs =
