Index: src/net/sf/freecol/server/generator/TerrainGenerator.java
===================================================================
--- src/net/sf/freecol/server/generator/TerrainGenerator.java	(revision 9954)
+++ src/net/sf/freecol/server/generator/TerrainGenerator.java	(working copy)
@@ -20,9 +20,7 @@
 package net.sf.freecol.server.generator;
 
 import java.awt.Rectangle;
-
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.EnumMap;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -48,8 +46,8 @@
 import net.sf.freecol.common.model.TileType;
 import net.sf.freecol.common.option.MapGeneratorOptions;
 import net.sf.freecol.common.option.OptionGroup;
-import net.sf.freecol.server.model.ServerRegion;
 import net.sf.freecol.common.util.RandomChoice;
+import net.sf.freecol.server.model.ServerRegion;
 
 
 /**
Index: src/net/sf/freecol/common/model/Market.java
===================================================================
--- src/net/sf/freecol/common/model/Market.java	(revision 9954)
+++ src/net/sf/freecol/common/model/Market.java	(working copy)
@@ -29,7 +29,6 @@
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 
-import net.sf.freecol.common.option.IntegerOption;
 import net.sf.freecol.common.util.Utils;
 
 import org.w3c.dom.Element;
Index: src/net/sf/freecol/common/networking/ServerAPI.java
===================================================================
--- src/net/sf/freecol/common/networking/ServerAPI.java	(revision 9955)
+++ src/net/sf/freecol/common/networking/ServerAPI.java	(working copy)
@@ -20,6 +20,8 @@
 
 package net.sf.freecol.common.networking;
 
+import java.io.IOException;
+import java.net.ConnectException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -28,6 +30,7 @@
 
 import javax.xml.stream.XMLStreamException;
 
+import net.sf.freecol.FreeCol;
 import net.sf.freecol.common.debug.FreeColDebugger;
 import net.sf.freecol.common.model.AbstractUnit;
 import net.sf.freecol.common.model.BuildableType;
@@ -43,7 +46,10 @@
 import net.sf.freecol.common.model.Location;
 import net.sf.freecol.common.model.Map.Direction;
 import net.sf.freecol.common.model.Monarch.MonarchAction;
+import net.sf.freecol.common.model.Nation;
+import net.sf.freecol.common.model.NationOptions.NationState;
 import net.sf.freecol.common.model.NationSummary;
+import net.sf.freecol.common.model.NationType;
 import net.sf.freecol.common.model.Player;
 import net.sf.freecol.common.model.Region;
 import net.sf.freecol.common.model.Settlement;
@@ -54,6 +60,7 @@
 import net.sf.freecol.common.model.Unit.UnitState;
 import net.sf.freecol.common.model.UnitType;
 import net.sf.freecol.common.model.WorkLocation;
+import net.sf.freecol.common.option.OptionGroup;
 
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -1165,4 +1172,110 @@
         this.client = client;
         
     }
+
+    public void resetClient() {
+        this.client = null;
+        
+    }
+    
+    /**
+     * Connects a client to host:port (or more).
+     *
+     * @param threadName The name for the thread.
+     * @param host The name of the machine running the
+     *            <code>FreeColServer</code>.
+     * @param port The port to use when connecting to the host.
+     * @throws ConnectException
+     * @throws IOException
+     */
+    public void connect(MessageHandler messageHandler, String threadName, String host, int port)
+        throws ConnectException, IOException {
+        int tries;
+        if (port < 0) {
+            port = FreeCol.getDefaultPort();
+            tries = 10;
+        } else {
+            tries = 1;
+        }
+        for (int i = tries; i > 0; i--) {
+            try {
+                client = new Client(host, port,
+                                    messageHandler,
+                                    threadName);
+                if (client != null) break;
+            } catch (ConnectException e) {
+                if (i == 1) throw e;
+            } catch (IOException e) {
+                if (i == 1) throw e;
+            }
+        }
+    }
+
+    public void disconnect() {
+        if (client != null)
+            client.disconnect();
+    }
+
+    public void logout() {
+        client.sendAndWait(DOMMessage.createMessage("logout",
+                "reason", "User has quit the client."));
+        
+    }
+
+    public void requestLaunch() {
+        client.send(DOMMessage.createMessage("requestLaunch"));        
+    }
+
+    public void updateGameOptions(OptionGroup gameOptions) {
+        Element up = DOMMessage.createMessage("updateGameOptions");
+        up.appendChild(gameOptions.toXMLElement(up.getOwnerDocument()));
+        client.send(up);        
+    }
+
+    public void updateMapGeneratorOptions(OptionGroup mapOptions) {
+        Element up = DOMMessage.createMessage("updateMapGeneratorOptions");
+        up.appendChild(mapOptions.toXMLElement(up.getOwnerDocument()));
+        client.send(up);        
+    }
+
+    public void setReady(boolean ready) {
+        client.send(DOMMessage.createMessage("ready",
+                "value", Boolean.toString(ready)));
+
+        
+    }
+
+    public void setNation(Nation nation) {
+        client.sendAndWait(DOMMessage.createMessage("setNation",
+                "value", nation.getId()));
+        
+    }
+
+    public void setNationType(NationType nationType) {
+        client.sendAndWait(DOMMessage.createMessage("setNationType",
+                    "value", nationType.getId()));        
+    }
+
+    public void setAvailable(Nation nation, NationState state) {
+        client
+            .sendAndWait(DOMMessage.createMessage("setAvailable",
+                    "nation", nation.getId(),
+                    "state", state.toString()));    }
+
+    public String getHost() {
+        return client.getHost();
+    }
+
+    public int getPort() {
+        return client.getPort();
+    }
+
+    public void setMessageHandler(MessageHandler messageHandler) {
+        client.setMessageHandler(messageHandler);
+        
+    }
+
+    public Connection getConnection() {
+        return client.getConnection();
+    }
 }
Index: src/net/sf/freecol/client/control/PreGameController.java
===================================================================
--- src/net/sf/freecol/client/control/PreGameController.java	(revision 9954)
+++ src/net/sf/freecol/client/control/PreGameController.java	(working copy)
@@ -35,15 +35,12 @@
 import net.sf.freecol.common.model.NationType;
 import net.sf.freecol.common.model.Player;
 import net.sf.freecol.common.model.Tile;
-import net.sf.freecol.common.networking.ChatMessage;
-import net.sf.freecol.common.networking.DOMMessage;
 import net.sf.freecol.common.option.MapGeneratorOptions;
 import net.sf.freecol.common.option.OptionGroup;
 import net.sf.freecol.common.resources.ChipResource;
 import net.sf.freecol.common.resources.ResourceManager;
 import net.sf.freecol.common.resources.ResourceMapping;
 
-import org.w3c.dom.Element;
 
 
 
@@ -81,9 +78,8 @@
      */
     public void setReady(boolean ready) {
         freeColClient.getMyPlayer().setReady(ready);
-
-        freeColClient.getClient().send(DOMMessage.createMessage("ready",
-                "value", Boolean.toString(ready)));
+        
+        freeColClient.askServer().setReady(ready);
     }
 
     /**
@@ -93,10 +89,9 @@
      */
     public void setNation(Nation nation) {
         freeColClient.getMyPlayer().setNation(nation);
+        
+        freeColClient.askServer().setNation(nation);
 
-        freeColClient.getClient()
-            .sendAndWait(DOMMessage.createMessage("setNation",
-                    "value", nation.getId()));
     }
 
     /**
@@ -107,9 +102,7 @@
     public void setNationType(NationType nationType) {
         freeColClient.getMyPlayer().setNationType(nationType);
 
-        freeColClient.getClient()
-            .sendAndWait(DOMMessage.createMessage("setNationType",
-                    "value", nationType.getId()));
+        freeColClient.askServer().setNationType(nationType);
     }
 
     /**
@@ -121,11 +114,9 @@
     public void setAvailable(Nation nation, NationState state) {
         freeColClient.getGame().getNationOptions()
             .getNations().put(nation, state);
+        
+        freeColClient.askServer().setAvailable(nation, state);
 
-        freeColClient.getClient()
-            .sendAndWait(DOMMessage.createMessage("setAvailable",
-                    "nation", nation.getId(),
-                    "state", state.toString()));
     }
 
     /**
@@ -135,8 +126,8 @@
     public void requestLaunch() {
         if (freeColClient.getGame().isAllPlayersReadyToLaunch()) {
             gui.showStatusPanel(Messages.message("status.startingGame"));
-            freeColClient.getClient()
-                .send(DOMMessage.createMessage("requestLaunch"));
+            freeColClient.askServer().requestLaunch();
+            
         } else {
             gui.errorMessage("server.notAllReady");
         }
@@ -148,9 +139,8 @@
      * @param message The text of the message.
      */
     public void chat(String message) {
-        freeColClient.getClient()
-            .send(new ChatMessage(freeColClient.getMyPlayer(),
-                    message, Boolean.FALSE).toXMLElement());
+        freeColClient.askServer().chat(freeColClient.getMyPlayer(), message);
+        
     }
 
     /**
@@ -161,9 +151,8 @@
         OptionGroup gameOptions = freeColClient.getGame().getSpecification()
             .getOptionGroup("gameOptions");
 
-        Element up = DOMMessage.createMessage("updateGameOptions");
-        up.appendChild(gameOptions.toXMLElement(up.getOwnerDocument()));
-        freeColClient.getClient().send(up);
+        freeColClient.askServer().updateGameOptions(gameOptions);
+
     }
 
     /**
@@ -174,10 +163,8 @@
         OptionGroup mapOptions = freeColClient.getGame()
             .getMapGeneratorOptions();
 
-        Element up = DOMMessage.createMessage("updateMapGeneratorOptions");
-        up.appendChild(mapOptions.toXMLElement(up.getOwnerDocument()));
-        //freeColClient.getGame().setMapGeneratorOptions(mapGeneratorOptions);
-        freeColClient.getClient().send(up);
+        freeColClient.askServer().updateMapGeneratorOptions(mapOptions);
+
     }
 
     /**
@@ -215,7 +202,7 @@
             gui.playSound(null); // Stop the long introduction sound
             gui.playSound("sound.intro." + myPlayer.getNationID());
         }
-        freeColClient.getClient()
+        freeColClient.askServer()
             .setMessageHandler(freeColClient.getInGameInputHandler());
 
         if (!freeColClient.isHeadless()) {
Index: src/net/sf/freecol/client/control/ConnectController.java
===================================================================
--- src/net/sf/freecol/client/control/ConnectController.java	(revision 9954)
+++ src/net/sf/freecol/client/control/ConnectController.java	(working copy)
@@ -24,7 +24,6 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.ConnectException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.logging.Level;
@@ -51,7 +50,6 @@
 import net.sf.freecol.common.model.Specification;
 import net.sf.freecol.common.model.Tile;
 import net.sf.freecol.common.model.Unit;
-import net.sf.freecol.common.networking.Client;
 import net.sf.freecol.common.networking.Connection;
 import net.sf.freecol.common.networking.DOMMessage;
 import net.sf.freecol.common.networking.LoginMessage;
@@ -255,41 +253,7 @@
         }
     }
 
-    /**
-     * Connects a client to host:port (or more).
-     *
-     * @param threadName The name for the thread.
-     * @param host The name of the machine running the
-     *            <code>FreeColServer</code>.
-     * @param port The port to use when connecting to the host.
-     * @return The client.
-     * @throws ConnectException
-     * @throws IOException
-     */
-    private Client connectClient(String threadName, String host, int port)
-        throws ConnectException, IOException {
-        Client client = null;
-        int tries;
-        if (port < 0) {
-            port = FreeCol.getDefaultPort();
-            tries = 10;
-        } else {
-            tries = 1;
-        }
-        for (int i = tries; i > 0; i--) {
-            try {
-                client = new Client(host, port,
-                                    freeColClient.getPreGameInputHandler(),
-                                    threadName);
-                if (client != null) break;
-            } catch (ConnectException e) {
-                if (i == 1) throw e;
-            } catch (IOException e) {
-                if (i == 1) throw e;
-            }
-        }
-        return client;
-    }
+ 
 
     /**
      * Starts the client and connects to <i>host:port</i>.
@@ -303,18 +267,16 @@
      */
     public boolean login(String userName, String host, int port) {
         freeColClient.setMapEditor(false);
- 
-        Client client = freeColClient.getClient();
-        if (client != null) client.disconnect();
 
+        freeColClient.askServer().disconnect();
+
         try {
-            client = connectClient(FreeCol.CLIENT_THREAD + userName,
-                                   host, port);
+            freeColClient.askServer().connect(freeColClient.getPreGameInputHandler(),
+                         FreeCol.CLIENT_THREAD + userName, host, port);
         } catch (Exception e) {
             gui.errorMessage("server.couldNotConnect", e.getMessage());
             return false;
         }
-        freeColClient.setClient(client);
 
         LoginMessage msg = freeColClient.askServer()
             .login(userName, FreeCol.getVersion());
@@ -369,8 +331,8 @@
      */
     public void reconnect() {
         final String userName = freeColClient.getMyPlayer().getName();
-        final String host = freeColClient.getClient().getHost();
-        final int port = freeColClient.getClient().getPort();
+        final String host = freeColClient.askServer().getHost();
+        final int port = freeColClient.askServer().getPort();
 
         gui.removeInGameComponents();
         logout(true);
@@ -556,11 +518,10 @@
      */
     public void logout(boolean notifyServer) {
         if (notifyServer) {
-            freeColClient.getClient()
-                .sendAndWait(DOMMessage.createMessage("logout",
-                        "reason", "User has quit the client."));
+            freeColClient.askServer().logout();
+            
         }
-        freeColClient.getClient().getConnection().close();
+        freeColClient.askServer().disconnect();
 
         ResourceManager.setScenarioMapping(null);
         ResourceManager.setCampaignMapping(null);
@@ -570,7 +531,7 @@
         }
         freeColClient.setGame(null);
         freeColClient.setMyPlayer(null);
-        freeColClient.setClient(null);
+        freeColClient.askServer().resetClient();;
         freeColClient.setLoggedIn(false);
     }
 
Index: src/net/sf/freecol/client/gui/menu/DebugMenu.java
===================================================================
--- src/net/sf/freecol/client/gui/menu/DebugMenu.java	(revision 9954)
+++ src/net/sf/freecol/client/gui/menu/DebugMenu.java	(working copy)
@@ -494,7 +494,7 @@
                 public void actionPerformed(ActionEvent e) {
                     AIMain aiMain = server.getAIMain();
                     AIPlayer ap = aiMain.getAIPlayer(player);
-                    ap.setDebuggingConnection(freeColClient.getClient().getConnection());
+                    ap.setDebuggingConnection(freeColClient.askServer().getConnection());
                     ap.startWorking();
                     freeColClient.getConnectController().reconnect();
                 }
Index: src/net/sf/freecol/client/FreeColClient.java
===================================================================
--- src/net/sf/freecol/client/FreeColClient.java	(revision 9955)
+++ src/net/sf/freecol/client/FreeColClient.java	(working copy)
@@ -543,17 +543,6 @@
     }
 
     /**
-     * Sets the <code>Client</code> that shall be used to send messages to the
-     * server.
-     *
-     * @param client The <code>Client</code>.
-     * @see #getClient
-     */
-    public void setClient(Client client) {
-        serverAPI.setClient(client);
-    }
-
-    /**
      * Sets the <code>FreeColServer</code> which has been started by the
      * client gui.
      *
