Index: src/mlx/gui/flight.py
===================================================================
--- src/mlx/gui/flight.py	(revision 86)
+++ src/mlx/gui/flight.py	(revision 88)
@@ -1373,4 +1373,6 @@
         super(LandingPage, self).__init__(wizard, "Landing", help)
 
+        self._flightEnded = False
+
         alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
                                   xscale = 0.0, yscale = 0.0)
@@ -1475,4 +1477,6 @@
     def activate(self):
         """Called when the page is activated."""
+        self._flightEnded = False
+        
         self._starButton.set_sensitive(True)
         self._starButton.set_active(False)
@@ -1492,4 +1496,9 @@
         self._vref.set_sensitive(True)
 
+        self._updateForwardButton()
+
+    def flightEnded(self):
+        """Called when the flight has ended."""
+        self._flightEnded = True
         self._updateForwardButton()
 
@@ -1526,5 +1535,6 @@
     def _updateForwardButton(self, widget = None):
         """Update the sensitivity of the forward button."""
-        sensitive = (self._starButton.get_active() or \
+        sensitive = self._flightEnded and \
+                    (self._starButton.get_active() or \
                      self._transitionButton.get_active()) and \
                     (self._star.get_text()!="" or
@@ -1680,4 +1690,6 @@
         if stage==const.STAGE_TAKEOFF:
             self._takeoffPage.freezeValues()
+        elif stage==const.STAGE_END:
+            self._landingPage.flightEnded()
 
     def _initialize(self):
Index: src/mlx/gui/gui.py
===================================================================
--- src/mlx/gui/gui.py	(revision 86)
+++ src/mlx/gui/gui.py	(revision 88)
@@ -150,10 +150,7 @@
         gtk.main()
 
-        if self._flight is not None:
-            simulator = self._flight.simulator
-            if self._monitoring:
-                simulator.stopMonitoring()
-                self._monitoring = False
-            simulator.disconnect()                        
+        if self._flight is not None and self._connected:
+            self.stopMonitoring()
+            self._flight.simulator.disconnect()                        
 
     def connected(self, fsType, descriptor):
@@ -265,4 +262,10 @@
         self._statusIcon.setStage(stage)
         self._wizard.setStage(stage)
+        if stage==const.STAGE_END:
+            self.stopMonitoring()
+            self.simulator.disconnect()
+            self._connecting = False
+            self._connected = False
+            self._statusbar.updateConnection(self._connecting, self._connected)
 
     def setRating(self, rating):
@@ -412,11 +415,13 @@
     def startMonitoring(self):
         """Start monitoring."""
-        self._simulator.startMonitoring()
-        self._monitoring = True
+        if not self._monitoring:
+            self.simulator.startMonitoring()
+            self._monitoring = True
 
     def stopMonitoring(self):
         """Stop monitoring."""
-        self._simulator.stoptMonitoring()
-        self._monitoring = False
+        if self._monitoring:
+            self.simulator.stopMonitoring()
+            self._monitoring = False
 
     def _buildLogFrame(self):
Index: src/mlx/pyuipc_sim.py
===================================================================
--- src/mlx/pyuipc_sim.py	(revision 85)
+++ src/mlx/pyuipc_sim.py	(revision 88)
@@ -351,12 +351,13 @@
             index = 0
             while index<numNotchesM1 and \
-                  self.flapsControl<self.flapsNotches[index]:
+                  self.flapsControl>self.flapsNotches[index]:
                 index += 1
-                
+
             if index==numNotchesM1:
                 return 16383
             else:
-                return int((self.flapsControl-self.flapsNotches[index]) * \
-                           flapsIncrement / \
+                return int(index * flapsIncrement +
+                           (self.flapsControl-self.flapsNotches[index]) *
+                           flapsIncrement /
                            (self.flapsNotches[index+1] - self.flapsNotches[index]))
         elif offset==0x0be0 or offset==0x0be4:    # Flaps left and  right
@@ -529,10 +530,10 @@
             numNotchesM1 = len(self.flapsNotches) - 1
             flapsIncrement = 16383.0 / numNotchesM1
-            index = value / flapsIncrement
+            index = int(value / flapsIncrement)
             if index>=numNotchesM1:
                 self.flapsControl = self.flapsNotches[-1]
             else:
                 self.flapsControl = self.flapsNotches[index]
-                self.flapsControl += value * \
+                self.flapsControl += (value - index * flapsIncrement) * \
                     (self.flapsNotches[index+1] - self.flapsNotches[index]) / \
                     flapsIncrement
@@ -583,5 +584,4 @@
         elif offset==0x3bfc:       # ZFW
             self.zfw = value * const.LBSTOKG / 256.0
-            print "ZFW:", self.zfw
         elif offset==0x3c00:       # Path of the current AIR file
             self.airPath = value
@@ -640,5 +640,5 @@
         temperature += 273.15  # Celsius -> Kelvin
         airDensity = pressure / (temperature * 287.05)
-        print "pressure:", pressure, "temperature:", temperature, "airDensity:", airDensity
+        #print "pressure:", pressure, "temperature:", temperature, "airDensity:", airDensity
         return self.ias * math.sqrt(1.225 / airDensity)
 
Index: src/mlx/web.py
===================================================================
--- src/mlx/web.py	(revision 74)
+++ src/mlx/web.py	(revision 88)
@@ -337,5 +337,5 @@
         result = Result()
 
-        f = urllib2.urlopen(url)
+        f = urllib2.urlopen(url, timeout = 10.0)
 
         status = readline(f)
@@ -375,5 +375,5 @@
         url = "http://www.virtualairlines.hu/onlinegates_get.php"
 
-        f = urllib2.urlopen(url)
+        f = urllib2.urlopen(url, timeout = 10.0)
         result = Result()
         result.fleet = Fleet(f)
@@ -407,5 +407,5 @@
                                  ("kapu", gateNumber)])
         
-        f = urllib2.urlopen(url, data)
+        f = urllib2.urlopen(url, data, timeout = 10.0)
         line = readline(f)
         
@@ -434,5 +434,5 @@
         url = "http://notams.euroutepro.com/notams.xml"
 
-        f = urllib2.urlopen(url)
+        f = urllib2.urlopen(url, timeout = 10.0)
         try:
             xmlParser.parse(f)
@@ -466,5 +466,5 @@
                                   ("mostRecentForEachStation", "constraint")])
         url += data
-        f = urllib2.urlopen(url)
+        f = urllib2.urlopen(url, timeout = 10.0)
         try:
             result = Result()
