diff --git a/gdb/gdbserver/inferiors.c b/gdb/gdbserver/inferiors.c
index 4d64250..25de573 100644
--- a/gdb/gdbserver/inferiors.c
+++ b/gdb/gdbserver/inferiors.c
@@ -22,11 +22,6 @@
  #include "gdbthread.h"
  #include "dll.h"

-struct inferior_list all_processes;
-struct inferior_list all_threads;
-
-struct thread_info *current_thread;
-
  #define get_thread(inf) ((struct thread_info *)(inf))

  void
diff --git a/gdb/gdbserver/inferiors.h b/gdb/gdbserver/inferiors.h
index d722616..d457a35 100644
--- a/gdb/gdbserver/inferiors.h
+++ b/gdb/gdbserver/inferiors.h
@@ -84,8 +84,6 @@ struct process_info
  struct process_info *current_process (void);
  struct process_info *get_thread_process (struct thread_info *);

-extern struct inferior_list all_processes;
-
  void add_inferior_to_list (struct inferior_list *list,
  			   struct inferior_list_entry *new_inferior);
  void for_each_inferior (struct inferior_list *list,
@@ -122,7 +120,6 @@ int one_inferior_p (struct inferior_list *list);
  #define ALL_PROCESSES(cur, tmp)					\
    ALL_INFERIORS_TYPE (struct process_info, &all_processes, cur, tmp)

-extern struct thread_info *current_thread;
  void remove_inferior (struct inferior_list *list,
  		      struct inferior_list_entry *entry);

diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 1f0a977..12a18d0 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -5627,8 +5627,6 @@ linux_look_up_symbols (void)
  static void
  linux_request_interrupt (void)
  {
-  extern unsigned long signal_pid;
-
    /* Send a SIGINT to the process group.  This acts just like the user
       typed a ^C on the controlling terminal.  */
    kill (-signal_pid, SIGINT);
diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index a00a9f5..3b1a763 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -860,14 +860,6 @@ initialize_async_io (void)
    unblock_async_io ();
  }

-/* Internal buffer used by readchar.
-   These are global to readchar because reschedule_remote needs to be
-   able to tell whether the buffer is empty.  */
-
-static unsigned char readchar_buf[BUFSIZ];
-static int readchar_bufcnt = 0;
-static unsigned char *readchar_bufp;
-
  /* Returns next char from remote GDB.  -1 if error.  */

  static int
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index ec408d3..7e9addf 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -36,60 +36,6 @@
  #include "dll.h"
  #include "hostio.h"

-/* The thread set with an `Hc' packet.  `Hc' is deprecated in favor of
-   `vCont'.  Note the multi-process extensions made `vCont' a
-   requirement, so `Hc pPID.TID' is pretty much undefined.  So
-   CONT_THREAD can be null_ptid for no `Hc' thread, minus_one_ptid for
-   resuming all threads of the process (again, `Hc' isn't used for
-   multi-process), or a specific thread ptid_t.  */
-ptid_t cont_thread;
-
-/* The thread set with an `Hg' packet.  */
-ptid_t general_thread;
-
-int server_waiting;
-
-static int extended_protocol;
-static int response_needed;
-static int exit_requested;
-
-/* --once: Exit after the first connection has closed.  */
-int run_once;
-
-int multi_process;
-int report_fork_events;
-int report_vfork_events;
-int report_exec_events;
-int report_thread_events;
-
-/* Whether to report TARGET_WAITKING_NO_RESUMED events.  */
-static int report_no_resumed;
-
-int non_stop;
-int swbreak_feature;
-int hwbreak_feature;
-
-/* True if the "vContSupported" feature is active.  In that case, GDB
-   wants us to report whether single step is supported in the reply to
-   "vCont?" packet.  */
-static int vCont_supported;
-
-/* Whether we should attempt to disable the operating system's address
-   space randomization feature before starting an inferior.  */
-int disable_randomization = 1;
-
-static char **program_argv, **wrapper_argv;
-
-int pass_signals[GDB_SIGNAL_LAST];
-int program_signals[GDB_SIGNAL_LAST];
-int program_signals_p;
-
-/* The PID of the originally created or attached inferior.  Used to
-   send signals to the process when GDB sends us an asynchronous interrupt
-   (user hitting Control-C in the client), and to wait for the child to 
exit
-   when no longer debugging it.  */
-
-unsigned long signal_pid;

  #ifdef SIGTTOU
  /* A file descriptor for the controlling terminal.  */
@@ -107,21 +53,6 @@ restore_old_foreground_pgrp (void)
  }
  #endif

-/* Set if you want to disable optional thread related packets support
-   in gdbserver, for the sake of testing GDB against stubs that don't
-   support them.  */
-int disable_packet_vCont;
-int disable_packet_Tthread;
-int disable_packet_qC;
-int disable_packet_qfThreadInfo;
-
-/* Last status reported to GDB.  */
-static struct target_waitstatus last_status;
-static ptid_t last_ptid;
-
-static char *own_buffer;
-static unsigned char *mem_buf;
-
  /* A sub-class of 'struct notif_event' for stop, holding information
     relative to a single stop reply.  We keep a queue of these to
     push to GDB in non-stop mode.  */
@@ -143,6 +74,28 @@ static struct btrace_config current_btrace_conf;

  DEFINE_QUEUE_P (notif_event_p);

+static client_state *current_client_state;
+
+/* Add a new client state for FD or return if found */
+
+client_state *
+new_client_state ()
+{
+  current_client_state = XCNEW (client_state);
+  current_client_state->ss = XCNEW (server_state);
+  own_buffer = (char *) xmalloc (PBUFSIZ + 1);
+  return current_client_state;
+}
+
+
+/* Return the current client state */
+
+client_state *
+get_client_state (void)
+{
+  return current_client_state;
+}
+
  /* Put a stop reply to the stop reply queue.  */

  static void
@@ -3458,6 +3411,8 @@ captured_main (int argc, char *argv[])
    volatile int attach = 0;
    int was_running;

+  new_client_state ();
+
    while (*next_arg != NULL && **next_arg == '-')
      {
        if (strcmp (*next_arg, "--version") == 0)
diff --git a/gdb/gdbserver/server.h b/gdb/gdbserver/server.h
index 18095f2..47bcab7 100644
--- a/gdb/gdbserver/server.h
+++ b/gdb/gdbserver/server.h
@@ -67,42 +67,6 @@ int vsnprintf(char *str, size_t size, const char 
*format, va_list ap);

  void initialize_low ();

-/* Public variables in server.c */
-
-extern ptid_t cont_thread;
-extern ptid_t general_thread;
-
-extern int server_waiting;
-extern int pass_signals[];
-extern int program_signals[];
-extern int program_signals_p;
-
-extern int disable_packet_vCont;
-extern int disable_packet_Tthread;
-extern int disable_packet_qC;
-extern int disable_packet_qfThreadInfo;
-
-extern int run_once;
-extern int multi_process;
-extern int report_fork_events;
-extern int report_vfork_events;
-extern int report_exec_events;
-extern int report_thread_events;
-extern int non_stop;
-
-/* True if the "swbreak+" feature is active.  In that case, GDB wants
-   us to report whether a trap is explained by a software breakpoint
-   and for the server to handle PC adjustment if necessary on this
-   target.  Only enabled if the target supports it.  */
-extern int swbreak_feature;
-
-/* True if the "hwbreak+" feature is active.  In that case, GDB wants
-   us to report whether a trap is explained by a hardware breakpoint.
-   Only enabled if the target supports it.  */
-extern int hwbreak_feature;
-
-extern int disable_randomization;
-
  #if USE_WIN32API
  #include <winsock2.h>
