From 72ba6909a825a22e1afa1a451ac2a41825024542 Mon Sep 17 00:00:00 2001
From: Ramakrishnan Muthukrishnan <ram@rkrishnan.org>
Date: Tue, 5 Dec 2023 18:55:11 +0530
Subject: [PATCH] use iwyu to rewrite the #include statements in all .c/.h
 files

---
 about_menu.c              |  27 ++-
 about_menu.h              |   2 +
 action_dialog.c           |   8 +-
 actions.c                 |  59 +++----
 actions.h                 |   1 +
 adc.h                     |   2 +
 agc_menu.c                |  28 ++--
 agc_menu.h                |   1 +
 ant_menu.c                |  25 +--
 ant_menu.h                |   2 +
 band.c                    |  24 +--
 band.h                    |   1 +
 band_menu.c               |  32 ++--
 band_menu.h               |   2 +
 bandstack_menu.c          |  30 ++--
 bandstack_menu.h          |   1 +
 button_text.c             |   6 +-
 configure.c               |  30 ++--
 css.c                     |   6 +-
 cw_menu.c                 |  34 ++--
 cw_menu.h                 |   1 +
 discovered.c              |   1 -
 discovery.c               |  59 +++----
 display_menu.c            |  26 ++-
 display_menu.h            |   2 +
 diversity_menu.c          |  29 ++--
 diversity_menu.h          |   1 +
 dsp_menu.c                |  26 ++-
 dsp_menu.h                |   1 +
 encoder_menu.c            |  33 ++--
 equalizer_menu.c          |  25 ++-
 equalizer_menu.h          |   1 +
 error_handler.c           |  12 +-
 exit_menu.c               |  30 ++--
 exit_menu.h               |   2 +
 ext.c                     |  61 ++++---
 fft_menu.c                |  20 +--
 fft_menu.h                |   1 +
 filter.c                  |  17 +-
 filter_menu.c             |  34 ++--
 filter_menu.h             |   1 +
 gpio.c                    |  63 +++----
 gpio.h                    |   3 +
 gpio.props                | 345 ++++++++++++++++++++++++++++++++++++++
 i2c.c                     |  30 +---
 led.c                     |   8 +-
 main.c                    |  62 +++----
 main.h                    |   7 +-
 memory.c                  |   6 +-
 meter.c                   |  30 ++--
 meter.h                   |   3 +-
 meter_menu.c              |  23 ++-
 meter_menu.h              |   1 +
 mode_menu.c               |  30 ++--
 nb_menu.c                 |  23 ++-
 nb_menu.h                 |   1 +
 new_discovery.c           |  31 ++--
 new_menu.c                |  91 +++++-----
 new_menu.h                |   2 +
 new_protocol.c            |  67 +++-----
 new_protocol_programmer.c |  36 ++--
 noise_menu.c              |  30 ++--
 noise_menu.h              |   1 +
 oc_menu.c                 |  27 ++-
 oc_menu.h                 |   1 +
 old_discovery.c           |  36 ++--
 old_protocol.c            |  63 +++----
 old_protocol.h            |   2 +
 pa_menu.c                 |  23 +--
 pa_menu.h                 |   2 -
 property.c                |  10 +-
 property.h                |   1 +
 protocols.c               |  19 +--
 protocols.h               |   3 +
 radio.c                   | 106 +++++-------
 radio.h                   |  12 +-
 radio_menu.c              |  45 ++---
 radio_menu.h              |   2 +
 receiver.c                |  61 +++----
 receiver.h                |  14 +-
 rigctl.c                  |  77 ++++-----
 rigctl.h                  |   4 +-
 rigctl_menu.c             |  26 ++-
 rigctl_menu.h             |   5 +-
 rx_menu.c                 |  34 ++--
 rx_menu.h                 |   2 +
 rx_panadapter.c           |  45 ++---
 rx_panadapter.h           |   2 +
 sliders.c                 |  45 ++---
 sliders.h                 |   6 +-
 step_menu.c               |  23 +--
 step_menu.h               |   1 +
 store.c                   |  21 +--
 store_menu.c              |  36 ++--
 store_menu.h              |   4 +
 switch_menu.c             |  35 ++--
 toolbar.c                 |  49 ++----
 toolbar.h                 |   5 +-
 toolbar_menu.c            |  35 ++--
 transmitter.c             |  56 +++----
 transmitter.h             |   4 +-
 tx_menu.c                 |  31 ++--
 tx_menu.h                 |   1 +
 tx_panadapter.c           |  43 ++---
 tx_panadapter.h           |   2 +
 vfo.c                     |  60 +++----
 vfo.h                     |   4 +-
 vfo_menu.c                |  34 ++--
 vox.c                     |  13 +-
 vox.h                     |   2 +
 vox_menu.c                |  27 ++-
 vox_menu.h                |   3 +
 waterfall.c               |  21 +--
 waterfall.h               |   2 +
 xvtr_menu.c               |  30 ++--
 xvtr_menu.h               |   1 +
 zoompan.c                 |  31 ++--
 zoompan.h                 |   2 +
 118 files changed, 1465 insertions(+), 1381 deletions(-)
 create mode 100644 gpio.props

diff --git a/about_menu.c b/about_menu.c
index 984b742..e5bb7ae 100644
--- a/about_menu.c
+++ b/about_menu.c
@@ -17,21 +17,20 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <ctype.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <stdbool.h>
-#include <wdsp.h>
-
-#include "new_menu.h"
 #include "about_menu.h"
-#include "discovered.h"
-#include "radio.h"
+#include <arpa/inet.h>         // for inet_ntoa
+#include <gdk/gdk.h>           // for GdkRGBA, GdkEvent, GdkEventButton
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for TRUE, gboolean, gpointer, FALSE
+#include <gtk/gtk.h>           // for GtkWidget, gtk_grid_attach, GTK_GRID
+#include <netinet/in.h>        // for sockaddr_in
+#include <stdio.h>             // for sprintf, NULL
+#include <string.h>            // for strcat, strcpy
+#include <wdsp.h>              // for GetWDSPVersion
+#include "discovered.h"        // for DISCOVERED, _DISCOVERED::(anonymous)
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "new_menu.h"          // for sub_menu
+#include "radio.h"             // for radio
 
 static GtkWidget *parent_window=NULL;
 static GtkWidget *dialog=NULL;
diff --git a/about_menu.h b/about_menu.h
index 5fb30d3..7ade667 100644
--- a/about_menu.h
+++ b/about_menu.h
@@ -17,4 +17,6 @@
 *
 */
 
+#include <gtk/gtk.h>  // for GtkWidget
+
 extern void about_menu(GtkWidget *parent);
diff --git a/action_dialog.c b/action_dialog.c
index 0e4cd48..257dc07 100644
--- a/action_dialog.c
+++ b/action_dialog.c
@@ -1,5 +1,9 @@
-#include <gtk/gtk.h>
-#include "actions.h"
+#include <glib-object.h>       // for g_signal_handler_block, g_signal_handl...
+#include <glib.h>              // for g_malloc0, TRUE, g_free, g_malloc0_n
+#include <gtk/gtk.h>           // for GtkWidget, gtk_container_add, gtk_togg...
+#include <stddef.h>            // for NULL
+#include "actions.h"           // for ACTION_TABLE, ActionTable, ACTIONS
+#include "gobject/gclosure.h"  // for G_CALLBACK
 
 #define GRID_WIDTH 6
 
diff --git a/actions.c b/actions.c
index 276caf5..725603a 100644
--- a/actions.c
+++ b/actions.c
@@ -1,38 +1,29 @@
-#include <gtk/gtk.h>
-#include <stdbool.h>
-
-#include "main.h"
-#include "discovery.h"
-#include "receiver.h"
-#include "sliders.h"
-#include "band_menu.h"
-#include "diversity_menu.h"
-#include "vfo.h"
-#include "radio.h"
-#include "radio_menu.h"
-#include "new_menu.h"
-#include "new_protocol.h"
-#ifdef PURESIGNAL
-#include "ps_menu.h"
-#endif
-#include "agc.h"
-#include "filter.h"
-#include "mode.h"
-#include "band.h"
-#include "bandstack.h"
-#include "noise_menu.h"
-#include "wdsp.h"
-#ifdef CLIENT_SERVER
-#include "client_server.h"
-#endif
-#include "ext.h"
-#include "zoompan.h"
 #include "actions.h"
-#include "gpio.h"
-#include "toolbar.h"
-#ifdef LOCALCW
-#include "iambic.h"
-#endif
+#include <glib/gtypes.h>     // for GINT_TO_POINTER
+#include <string.h>          // for NULL, strlen
+#include "adc.h"             // for ADC
+#include "agc.h"             // for AGC_LAST
+#include "band.h"            // for BAND, band_get_band, canTransmit, BANDS
+#include "bandstack.h"       // for BANDSTACK
+#include "discovered.h"      // for NEW_PROTOCOL, DISCOVERED
+#include "diversity_menu.h"  // for update_diversity_gain, update_diversity_...
+#include "ext.h"             // for ext_vfo_update, ext_num_pad, local_set_f...
+#include "filter.h"          // for filter_shift_changed, filter_width_changed
+#include "gpio.h"            // for switches_controller1, MAX_FUNCTIONS, swi...
+#include "iambic.h"          // for keyer_event
+#include "main.h"            // for CONTROLLER1, CONTROLLER2_V1, CONTROLLER2_V2
+#include "mode.h"            // for MODES, modeCWL, modeCWU, modeLSB, modeUSB
+#include "new_menu.h"        // for start_agc, start_band, start_bandstack
+#include "new_protocol.h"    // for schedule_high_priority, setMox, setTune
+#include "noise_menu.h"      // for update_noise
+#include "radio.h"           // for active_receiver, transmitter, receiver
+#include "receiver.h"        // for RECEIVER, set_agc, set_offset
+#include "sliders.h"         // for set_af_gain, set_agc_gain, set_rf_gain
+#include "toolbar.h"         // for function, update_toolbar_labels, mox_update
+#include "transmitter.h"     // for TRANSMITTER, transmitter_set_out_of_band
+#include "vfo.h"             // for _vfo, vfo_band_changed, vfo, _mode_settings
+#include "wdsp.h"            // for SetRXAANFRun
+#include "zoompan.h"         // for update_pan, update_zoom
 
 ACTION_TABLE ActionTable[] = {
   {NO_ACTION,		"NONE",			NULL,		TYPE_NONE},
diff --git a/actions.h b/actions.h
index 13d18a4..66f6fda 100644
--- a/actions.h
+++ b/actions.h
@@ -1,3 +1,4 @@
+#include <glib.h>  // for gint
 
 enum ACTION {
   NO_ACTION=0,
diff --git a/adc.h b/adc.h
index 9cedcbb..85f6494 100644
--- a/adc.h
+++ b/adc.h
@@ -20,6 +20,8 @@
 #ifndef ADC_H
 #define ADC_H
 
+#include <stdbool.h>
+
 enum {
   AUTOMATIC=0,
   MANUAL
diff --git a/agc_menu.c b/agc_menu.c
index 16bdbf9..d34a9ed 100644
--- a/agc_menu.c
+++ b/agc_menu.c
@@ -17,23 +17,19 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "new_menu.h"
 #include "agc_menu.h"
-#include "agc.h"
-#include "band.h"
-#include "channel.h"
-#include "radio.h"
-#include "receiver.h"
-#include "vfo.h"
-#include "button_text.h"
-#include "ext.h"
+#include <gdk/gdk.h>           // for GdkRGBA, GdkEvent, GdkEventButton
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for gpointer, TRUE, g_idle_add, gboolean
+#include <glib/gtypes.h>       // for GPOINTER_TO_INT
+#include <gtk/gtk.h>           // for gtk_grid_attach, gtk_toggle_button_set...
+#include <stdio.h>             // for NULL, sprintf
+#include "agc.h"               // for AGC_FAST, AGC_LONG, AGC_MEDIUM, AGC_OFF
+#include "ext.h"               // for ext_vfo_update
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "new_menu.h"          // for sub_menu, NO_MENU, active_menu
+#include "radio.h"             // for active_receiver
+#include "receiver.h"          // for RECEIVER, set_agc
 
 static GtkWidget *parent_window=NULL;
 
diff --git a/agc_menu.h b/agc_menu.h
index d6ee1dd..5674412 100644
--- a/agc_menu.h
+++ b/agc_menu.h
@@ -16,5 +16,6 @@
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
+#include <gtk/gtk.h>  // for GtkWidget
 
 extern void agc_menu(GtkWidget *parent);
diff --git a/ant_menu.c b/ant_menu.c
index 914e078..aaf5fee 100644
--- a/ant_menu.c
+++ b/ant_menu.c
@@ -17,19 +17,20 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <semaphore.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "new_menu.h"
 #include "ant_menu.h"
-#include "band.h"
-#include "radio.h"
-#include "new_protocol.h"
+#include <gdk/gdk.h>           // for GdkRGBA, GdkEventButton, GdkEvent
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for gpointer, TRUE, gboolean, FALSE
+#include <glib/gtypes.h>       // for GPOINTER_TO_UINT
+#include <gtk/gtk.h>           // for gtk_grid_attach, gtk_widget_show, gtk_...
+#include <stdio.h>             // for NULL
+#include <string.h>            // for strlen
+#include "band.h"              // for BAND, BANDS, band_get_band, XVTRS, band10
+#include "discovered.h"        // for NEW_PROTOCOL, ORIGINAL_PROTOCOL, DEVIC...
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "new_menu.h"          // for sub_menu
+#include "radio.h"             // for device, protocol, new_pa_board, set_al...
+#include "receiver.h"          // for RECEIVER
 
 static GtkWidget *parent_window=NULL;
 static GtkWidget *dialog=NULL;
diff --git a/ant_menu.h b/ant_menu.h
index 3a847dc..5fb5b80 100644
--- a/ant_menu.h
+++ b/ant_menu.h
@@ -17,4 +17,6 @@
 *
 */
 
+#include <gtk/gtk.h>  // for GtkWidget
+
 void ant_menu(GtkWidget *parent);
diff --git a/band.c b/band.c
index 2581d97..9ade33d 100644
--- a/band.c
+++ b/band.c
@@ -17,19 +17,19 @@
 *
 */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "bandstack.h"
 #include "band.h"
-#include "filter.h"
-#include "mode.h"
-#include "alex.h"
-#include "property.h"
-#include "radio.h"
-#include "vfo.h"
+#include <glib.h>         // for g_print, TRUE
+#include <stdio.h>        // for sprintf, NULL
+#include <stdlib.h>       // for atoi, atoll, strtod
+#include <string.h>       // for strlen, strcpy
+#include "alex.h"         // for ALEX_ATTENUATION_0dB
+#include "bandstack.h"    // for BANDSTACK_ENTRY, BANDSTACK
+#include "filter.h"       // for filterF6, filterF5, filterF3
+#include "mode.h"         // for modeUSB, modeCWU, modeCWL, modeSAM, modeLSB
+#include "property.h"     // for setProperty, getProperty
+#include "radio.h"        // for cw_is_on_vfo_freq, cw_keyer_sidetone_frequency
+#include "transmitter.h"  // for TRANSMITTER
+#include "vfo.h"          // for _vfo, get_tx_freq, get_tx_mode, get_tx_vfo
 
 #define LINESDR
 
diff --git a/band.h b/band.h
index dfb51d1..893b57f 100644
--- a/band.h
+++ b/band.h
@@ -20,6 +20,7 @@
 #ifndef _BAND_H
 #define _BAND_H
 
+#include <stdbool.h>
 #include "bandstack.h"
 
 enum {
diff --git a/band_menu.c b/band_menu.c
index 73de711..d3c6c2a 100644
--- a/band_menu.c
+++ b/band_menu.c
@@ -17,25 +17,21 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "new_menu.h"
 #include "band_menu.h"
-#include "band.h"
-#include "bandstack.h"
-#include "filter.h"
-#include "radio.h"
-#include "receiver.h"
-#include "vfo.h"
-#include "button_text.h"
-#ifdef CLIENT_SERVER
-#include "client_server.h"
-#endif
+#include <gdk/gdk.h>           // for GdkRGBA, GdkEvent, GdkEventButton
+#include <glib-object.h>       // for g_signal_connect
+#include <glib/gtypes.h>       // for GPOINTER_TO_UINT
+#include <gtk/gtk.h>           // for GtkWidget, GTK_GRID, gtk_button_new_wi...
+#include <stdio.h>             // for NULL, sprintf
+#include <string.h>            // for strlen
+#include "band.h"              // for BAND, band_get_band, BANDS, XVTRS
+#include "button_text.h"       // for set_button_text_color
+#include "discovered.h"        // for DISCOVERED
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "new_menu.h"          // for sub_menu, NO_MENU, active_menu
+#include "radio.h"             // for active_receiver, radio
+#include "receiver.h"          // for RECEIVER
+#include "vfo.h"               // for vfo_band_changed, _vfo, vfo
 
 static GtkWidget *parent_window=NULL;
 
diff --git a/band_menu.h b/band_menu.h
index b9019af..37c1406 100644
--- a/band_menu.h
+++ b/band_menu.h
@@ -16,6 +16,8 @@
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
+#include <glib.h>     // for gboolean, gpointer
+#include <gtk/gtk.h>  // for GtkWidget
 
 extern void band_menu(GtkWidget *parent);
 extern gboolean band_select_cb (GtkWidget *widget, gpointer        data);
diff --git a/bandstack_menu.c b/bandstack_menu.c
index 5f58e3f..13a1db6 100644
--- a/bandstack_menu.c
+++ b/bandstack_menu.c
@@ -17,22 +17,22 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "new_menu.h"
 #include "bandstack_menu.h"
-#include "band.h"
-#include "bandstack.h"
-#include "filter.h"
-#include "radio.h"
-#include "receiver.h"
-#include "vfo.h"
-#include "button_text.h"
+#include <gdk/gdk.h>           // for GdkRGBA, GdkEvent, GdkEventButton
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for gpointer, TRUE, gboolean, FALSE
+#include <glib/gtypes.h>       // for GPOINTER_TO_UINT
+#include <gtk/gtk.h>           // for GtkWidget, GTK_GRID, gtk_button_new_wi...
+#include <stdio.h>             // for NULL, sprintf
+#include "band.h"              // for band_get_band, BAND
+#include "bandstack.h"         // for BANDSTACK_ENTRY, BANDSTACK
+#include "button_text.h"       // for set_button_text_color
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "mode.h"              // for mode_string
+#include "new_menu.h"          // for sub_menu, NO_MENU, active_menu
+#include "radio.h"             // for active_receiver
+#include "receiver.h"          // for RECEIVER
+#include "vfo.h"               // for _vfo, vfo_bandstack_changed, vfo
 
 static GtkWidget *parent_window=NULL;
 
diff --git a/bandstack_menu.h b/bandstack_menu.h
index 29a61cb..9eafad9 100644
--- a/bandstack_menu.h
+++ b/bandstack_menu.h
@@ -16,5 +16,6 @@
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
+#include <gtk/gtk.h>  // for GtkWidget
 
 extern void bandstack_menu(GtkWidget *parent);
diff --git a/button_text.c b/button_text.c
index 8a1afd5..bf3a061 100644
--- a/button_text.c
+++ b/button_text.c
@@ -1,4 +1,8 @@
-#include <gtk/gtk.h>
+#include <glib-object.h>         // for g_object_unref
+#include <glib.h>                // for g_snprintf, gchar
+#include <gtk/gtk.h>             // for gtk_style_context_add_provider, gtk_...
+#include <stddef.h>              // for NULL
+#include "gtk/gtkcssprovider.h"  // for gtk_css_provider_load_from_data, gtk...
 
 void set_button_text_color(GtkWidget *widget,char *color) {
   GtkStyleContext *style_context;
diff --git a/configure.c b/configure.c
index 0d8b08b..3a131d1 100644
--- a/configure.c
+++ b/configure.c
@@ -17,26 +17,16 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <glib.h>
-#include <glib/gprintf.h>
-#include <math.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <semaphore.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <stdbool.h>
-
-#include "main.h"
-#include "channel.h"
-#include "discovered.h"
-#include "actions.h"
-#include "gpio.h"
-#include "i2c.h"
-
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for g_print, gint, FALSE, TRUE, gchar, gpo...
+#include <glib/gprintf.h>      // for g_sprintf
+#include <gtk/gtk.h>           // for gtk_grid_attach, gtk_label_new, gtk_la...
+#include <stdio.h>             // for sprintf
+#include <stdlib.h>            // for NULL
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "gpio.h"              // for ENCODER, encoders, gpio_restore_state
+#include "i2c.h"               // for i2c_sw, i2c_address_1, i2c_device
+#include "main.h"              // for controller, CONTROLLER2_V2, CONTROLLER1
 
 #ifdef GPIO
 
diff --git a/css.c b/css.c
index c1cdccd..4e90a97 100644
--- a/css.c
+++ b/css.c
@@ -1,5 +1,9 @@
-#include <gtk/gtk.h>
 #include "css.h"
+#include <gdk/gdk.h>             // for gdk_display_get_default, gdk_display...
+#include <glib-object.h>         // for g_object_unref
+#include <gtk/gtk.h>             // for gtk_style_context_add_provider_for_s...
+#include <stddef.h>              // for NULL
+#include "gtk/gtkcssprovider.h"  // for gtk_css_provider_load_from_data, gtk...
 
 char *css=
 "  @define-color TOGGLE_ON rgb(100%,0%,0%);\n"
diff --git a/cw_menu.c b/cw_menu.c
index 58748b6..accbcd6 100644
--- a/cw_menu.c
+++ b/cw_menu.c
@@ -17,25 +17,21 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <semaphore.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "new_menu.h"
-#include "pa_menu.h"
-#include "band.h"
-#include "bandstack.h"
-#include "filter.h"
-#include "radio.h"
-#include "receiver.h"
-#include "new_protocol.h"
-#include "old_protocol.h"
-#include "iambic.h"
-#include "ext.h"
+#include <gdk/gdk.h>           // for GdkRGBA, GdkEvent, GdkEventButton
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for gpointer, g_idle_add, gboolean, FALSE
+#include <glib/gtypes.h>       // for GPOINTER_TO_UINT
+#include <gtk/gtk.h>           // for gtk_grid_attach, gtk_widget_show, GtkW...
+#include <stdint.h>            // for uintptr_t
+#include <stdio.h>             // for NULL
+#include "discovered.h"        // for NEW_PROTOCOL
+#include "ext.h"               // for ext_vfo_update
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "iambic.h"            // for keyer_update
+#include "new_menu.h"          // for sub_menu
+#include "new_protocol.h"      // for schedule_high_priority
+#include "radio.h"             // for cw_keyer_mode, cw_breakin, cw_is_on_vf...
+#include "receiver.h"          // for receiver_filter_changed
 
 static GtkWidget *parent_window=NULL;
 
diff --git a/cw_menu.h b/cw_menu.h
index 662b000..6aa6780 100644
--- a/cw_menu.h
+++ b/cw_menu.h
@@ -16,5 +16,6 @@
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
+#include <gtk/gtk.h>
 
 extern void cw_menu(GtkWidget *parent);
diff --git a/discovered.c b/discovered.c
index 15e8248..513f255 100644
--- a/discovered.c
+++ b/discovered.c
@@ -17,7 +17,6 @@
 *
 */
 
-#include <gtk/gtk.h>
 #include "discovered.h"
 
 int selected_device=0;
diff --git a/discovery.c b/discovery.c
index b3b6155..5c626f9 100644
--- a/discovery.c
+++ b/discovery.c
@@ -17,45 +17,26 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <gdk/gdk.h>
-#include <math.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <semaphore.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <stdbool.h>
-
-#ifdef MIDI
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#endif
-
-#include "discovered.h"
-#include "old_discovery.h"
-#include "new_discovery.h"
-#include "main.h"
-#include "radio.h"
-#ifdef USBOZY
-#include "ozyio.h"
-#endif
-#include "ext.h"
-#ifdef GPIO
-#include "actions.h"
-#include "gpio.h"
-#include "configure.h"
-#endif
-#include "protocols.h"
-#ifdef CLIENT_SERVER
-#include "client_server.h"
-#endif
-#include "property.h"
-#include "log.h"
+#include <arpa/inet.h>         // for inet_ntoa
+#include <gdk/gdk.h>           // for GdkEventButton, GdkRGBA, gdk_cursor_new
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for gpointer, TRUE, gboolean, g_idle_add
+#include <gtk/gtk.h>           // for gtk_grid_attach, GtkWidget, gtk_button...
+#include <netinet/in.h>        // for sockaddr_in, in_addr
+#include <stdio.h>             // for NULL, fclose, fopen, sprintf, fgets
+#include <string.h>            // for strnlen, strncpy
+#include <unistd.h>            // for _exit
+#include "configure.h"         // for configure_gpio
+#include "discovered.h"        // for DISCOVERED, _DISCOVERED::(anonymous)
+#include "ext.h"               // for ext_discovery
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "gpio.h"              // for gpio_set_defaults, gpio_restore_state
+#include "log.h"               // for log_trace, log_info
+#include "main.h"              // for status_text, controller, top_window
+#include "old_discovery.h"     // for old_discovery
+#include "pango/pango-font.h"  // for pango_font_description_from_string
+#include "protocols.h"         // for configure_protocols, protocols_restore...
+#include "radio.h"             // for start_radio, radio
 
 static GtkWidget *discovery_dialog;
 static DISCOVERED *d;
diff --git a/display_menu.c b/display_menu.c
index eae3c2b..7fbdb48 100644
--- a/display_menu.c
+++ b/display_menu.c
@@ -17,25 +17,21 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <semaphore.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "main.h"
-#include "new_menu.h"
 #include "display_menu.h"
-#include "channel.h"
-#include "radio.h"
-#include "wdsp.h"
+#include <gdk/gdk.h>           // for GdkRGBA, GdkEvent, GdkEventButton
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for gpointer, gboolean, FALSE, TRUE
+#include <glib/gtypes.h>       // for GPOINTER_TO_UINT
+#include <gtk/gtk.h>           // for gtk_grid_attach, gtk_widget_show, GtkW...
+#include <stdio.h>             // for NULL
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "new_menu.h"          // for sub_menu
+#include "radio.h"             // for active_receiver, reconfigure_radio
+#include "receiver.h"          // for RECEIVER, set_displaying
+#include "wdsp.h"              // for SetDisplayAverageMode, SetDisplayDetec...
 
 static GtkWidget *parent_window=NULL;
 
-static GtkWidget *menu_b=NULL;
-
 static GtkWidget *dialog=NULL;
 
 static void cleanup() {
diff --git a/display_menu.h b/display_menu.h
index dbfa763..265fc15 100644
--- a/display_menu.h
+++ b/display_menu.h
@@ -17,4 +17,6 @@
 *
 */
 
+#include <gtk/gtk.h>  // for GtkWidget
+
 extern void display_menu(GtkWidget *parent);
diff --git a/diversity_menu.c b/diversity_menu.c
index 04a8cd5..6439243 100644
--- a/diversity_menu.c
+++ b/diversity_menu.c
@@ -17,23 +17,22 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <semaphore.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <pthread.h>
-#include <stdbool.h>
-
-#include "new_menu.h"
 #include "diversity_menu.h"
-#include "radio.h"
-#include "new_protocol.h"
-#include "old_protocol.h"
-#include "sliders.h"
-#include "ext.h"
+#include <gdk/gdk.h>           // for GdkRGBA, GdkEvent, GdkEventButton
+#include <glib-object.h>       // for g_signal_connect, G_OBJECT
+#include <glib.h>              // for gpointer, g_idle_add, gboolean, FALSE
+#include <gtk/gtk.h>           // for gtk_grid_attach, gtk_widget_show, gtk_...
+#include <math.h>              // for round, cos, pow, sin
+#include <stdio.h>             // for NULL
+#include "discovered.h"        // for ORIGINAL_PROTOCOL, NEW_PROTOCOL
+#include "ext.h"               // for ext_vfo_update
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "new_menu.h"          // for sub_menu
+#include "new_protocol.h"      // for schedule_high_priority, schedule_recei...
+#include "old_protocol.h"      // for old_protocol_run, old_protocol_stop
+#include "radio.h"             // for div_gain, div_phase, diversity_enabled
+#include "sliders.h"           // for show_diversity_gain, show_diversity_phase
 
-#include <math.h> 
 
 static GtkWidget *parent_window=NULL;
 
diff --git a/diversity_menu.h b/diversity_menu.h
index b71588f..402f703 100644
--- a/diversity_menu.h
+++ b/diversity_menu.h
@@ -16,6 +16,7 @@
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
+#include <gtk/gtk.h>  // for GtkWidget
 
 extern void diversity_menu(GtkWidget *parent);
 extern void update_diversity_gain(double increment);
diff --git a/dsp_menu.c b/dsp_menu.c
index 452c68d..8535586 100644
--- a/dsp_menu.c
+++ b/dsp_menu.c
@@ -17,21 +17,19 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <semaphore.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "new_menu.h"
 #include "dsp_menu.h"
-#include "agc.h"
-#include "channel.h"
-#include "radio.h"
-#include "receiver.h"
-#include "wdsp.h"
+#include <gdk/gdk.h>           // for GdkRGBA, GdkEvent, GdkEventButton
+#include <glib-object.h>       // for g_signal_connect, G_OBJECT
+#include <glib.h>              // for gpointer, gboolean, FALSE, TRUE
+#include <glib/gtypes.h>       // for GPOINTER_TO_UINT
+#include <gtk/gtk.h>           // for gtk_grid_attach, gtk_widget_show, GtkW...
+#include <stdio.h>             // for NULL
+#include "agc.h"               // for AGC_LONG, AGC_SLOW
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "new_menu.h"          // for sub_menu
+#include "radio.h"             // for active_receiver
+#include "receiver.h"          // for RECEIVER
+#include "wdsp.h"              // for SetRXAAGCHangThreshold, SetRXAEMNRPosi...
 
 static GtkWidget *parent_window=NULL;
 
diff --git a/dsp_menu.h b/dsp_menu.h
index 8c3a25c..5bf81d2 100644
--- a/dsp_menu.h
+++ b/dsp_menu.h
@@ -16,5 +16,6 @@
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
+#include <gtk/gtk.h>  // for GtkWidget
 
 void dsp_menu(GtkWidget *parent);
diff --git a/encoder_menu.c b/encoder_menu.c
index e81c754..a84738a 100644
--- a/encoder_menu.c
+++ b/encoder_menu.c
@@ -17,26 +17,19 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <glib/gprintf.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "main.h"
-#include "new_menu.h"
-#include "agc_menu.h"
-#include "agc.h"
-#include "band.h"
-#include "channel.h"
-#include "radio.h"
-#include "receiver.h"
-#include "vfo.h"
-#include "button_text.h"
-#include "actions.h"
-#include "action_dialog.h"
-#include "gpio.h"
-#include "i2c.h"
+#include <gdk/gdk.h>           // for GdkEvent, GdkEventButton
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for TRUE, gboolean, gpointer, gint, FALSE
+#include <glib/gprintf.h>      // for g_sprintf
+#include <glib/gtypes.h>       // for GINT_TO_POINTER, GPOINTER_TO_INT
+#include <gtk/gtk.h>           // for gtk_grid_attach, gtk_widget_set_name
+#include <stdio.h>             // for NULL, sprintf
+#include "action_dialog.h"     // for action_dialog
+#include "actions.h"           // for ACTION_TABLE, ActionTable, CONTROLLER_...
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "gpio.h"              // for ENCODER, encoders
+#include "main.h"              // for CONTROLLER1, CONTROLLER2_V1, CONTROLLE...
+#include "new_menu.h"          // for sub_menu, NO_MENU, active_menu
 
 static GtkWidget *parent_window=NULL;
 
diff --git a/equalizer_menu.c b/equalizer_menu.c
index c0ca3ac..efd0bc9 100644
--- a/equalizer_menu.c
+++ b/equalizer_menu.c
@@ -17,20 +17,19 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <semaphore.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include <wdsp.h>
-
-#include "new_menu.h"
 #include "equalizer_menu.h"
-#include "radio.h"
-#include "channel.h"
+#include <gdk/gdk.h>           // for GdkRGBA, GdkEventButton, GdkEvent
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for gpointer, FALSE, gboolean, TRUE
+#include <glib/gtypes.h>       // for GPOINTER_TO_UINT
+#include <gtk/gtk.h>           // for gtk_scale_add_mark, gtk_range_set_value
+#include <stdio.h>             // for NULL
+#include <wdsp.h>              // for SetRXAEQRun, SetRXAGrphEQ, SetTXAEQRun
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "new_menu.h"          // for sub_menu
+#include "radio.h"             // for rx_equalizer, tx_equalizer, can_transmit
+#include "receiver.h"          // for RECEIVER
+#include "transmitter.h"       // for TRANSMITTER
 
 static GtkWidget *parent_window=NULL;
 
diff --git a/equalizer_menu.h b/equalizer_menu.h
index 3a370ef..00b904f 100644
--- a/equalizer_menu.h
+++ b/equalizer_menu.h
@@ -16,5 +16,6 @@
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
+#include <gtk/gtk.h>  // for GtkWidget
 
 void equalizer_menu(GtkWidget *parent);
diff --git a/error_handler.c b/error_handler.c
index 40f65fe..6aa108b 100644
--- a/error_handler.c
+++ b/error_handler.c
@@ -1,11 +1,9 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <gtk/gtk.h>
-#include <stdbool.h>
-
 #include "error_handler.h"
-#include "main.h"
+#include <glib.h>     // for g_idle_add, g_timeout_add, FALSE, gint, gpointer
+#include <gtk/gtk.h>  // for GtkWidget, gtk_container_add, gtk_dialog_get_co...
+#include <stdio.h>    // for sprintf, NULL, fprintf, stderr
+#include <stdlib.h>   // for exit
+#include "main.h"     // for top_window
 
 static GtkWidget *dialog;
 static gint timer;
diff --git a/exit_menu.c b/exit_menu.c
index d05ca68..c7a6dfe 100644
--- a/exit_menu.c
+++ b/exit_menu.c
@@ -17,23 +17,21 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <semaphore.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "main.h"
-#include "new_menu.h"
 #include "exit_menu.h"
-#include "discovery.h"
-#include "radio.h"
-#include "new_protocol.h"
-#include "old_protocol.h"
-#include "actions.h"
-#ifdef GPIO
-#include "gpio.h"
-#endif
+#include <gdk/gdk.h>           // for GdkRGBA, GdkEventButton, GdkEvent
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for gboolean, gpointer, TRUE, FALSE
+#include <gtk/gtk.h>           // for GtkWidget, gtk_button_new_with_label
+#include <stdio.h>             // for NULL
+#include <stdlib.h>            // for system
+#include <unistd.h>            // for _exit
+#include "discovered.h"        // for NEW_PROTOCOL, ORIGINAL_PROTOCOL
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "gpio.h"              // for gpio_close
+#include "new_menu.h"          // for sub_menu
+#include "new_protocol.h"      // for new_protocol_stop
+#include "old_protocol.h"      // for old_protocol_stop
+#include "radio.h"             // for radioSaveState, protocol
 
 static GtkWidget *parent_window=NULL;
 
diff --git a/exit_menu.h b/exit_menu.h
index 7fdb6f2..7021c12 100644
--- a/exit_menu.h
+++ b/exit_menu.h
@@ -1 +1,3 @@
+#include <gtk/gtk.h>  // for GtkWidget
+
 extern void exit_menu(GtkWidget *parent);
diff --git a/ext.c b/ext.c
index 06f52c0..811deee 100644
--- a/ext.c
+++ b/ext.c
@@ -17,40 +17,35 @@
 *
 */
 
-#include <stdint.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <gtk/gtk.h>
-#include <stdbool.h>
-
-#include "main.h"
-#include "discovery.h"
-#include "receiver.h"
-#include "sliders.h"
-#include "toolbar.h"
-#include "band_menu.h"
-#include "diversity_menu.h"
-#include "vfo.h"
-#include "radio.h"
-#include "radio_menu.h"
-#include "new_menu.h"
-#include "new_protocol.h"
-#ifdef PURESIGNAL
-#include "ps_menu.h"
-#endif
-#include "agc.h"
-#include "filter.h"
-#include "mode.h"
-#include "band.h"
-#include "bandstack.h"
-#include "noise_menu.h"
-#include "wdsp.h"
-#ifdef CLIENT_SERVER
-#include "client_server.h"
-#endif
 #include "ext.h"
-#include "zoompan.h"
+#include <glib.h>            // for g_idle_add, g_print, FALSE, g_timeout_add
+#include <glib/gtypes.h>     // for GPOINTER_TO_INT
+#include <gtk/gtk.h>         // for gtk_window_set_title, GTK_WINDOW
+#include <stdio.h>           // for NULL
+#include <stdlib.h>          // for free
+#include <string.h>          // for strlen
+#include "agc.h"             // for AGC_LAST
+#include "band.h"            // for BAND, band_get_band, BANDS, get_band_fro...
+#include "band_menu.h"       // for band_select_cb
+#include "bandstack.h"       // for BANDSTACK
+#include "discovered.h"      // for DISCOVERED, NEW_PROTOCOL
+#include "discovery.h"       // for discovery
+#include "diversity_menu.h"  // for update_diversity_gain, update_diversity_...
+#include "filter.h"          // for FILTERS
+#include "main.h"            // for top_window
+#include "mode.h"            // for MODES
+#include "new_menu.h"        // for start_filter, start_mode, start_band
+#include "new_protocol.h"    // for schedule_high_priority, schedule_receive...
+#include "noise_menu.h"      // for update_noise
+#include "radio.h"           // for active_receiver, transmitter, can_transmit
+#include "radio_menu.h"      // for setDuplex
+#include "receiver.h"        // for RECEIVER, set_agc, set_offset
+#include "sliders.h"         // for set_af_gain, set_agc_gain, set_attenuati...
+#include "toolbar.h"         // for function, mox_update, tune_update, updat...
+#include "transmitter.h"     // for TRANSMITTER, tx_set_mode, tx_set_twotone
+#include "vfo.h"             // for _vfo, vfo, _mode_settings, mode_settings
+#include "wdsp.h"            // for SetRXAANFRun
+#include "zoompan.h"         // for remote_set_pan, remote_set_zoom, set_pan
 
 
 // The following calls functions can be called usig g_idle_add
diff --git a/fft_menu.c b/fft_menu.c
index 815b334..c6b9866 100644
--- a/fft_menu.c
+++ b/fft_menu.c
@@ -17,17 +17,17 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <semaphore.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "new_menu.h"
 #include "fft_menu.h"
-#include "radio.h"
+#include <gdk/gdk.h>           // for GdkRGBA, GdkEvent, GdkEventButton
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for gpointer, gboolean, FALSE, TRUE
+#include <glib/gtypes.h>       // for GPOINTER_TO_UINT
+#include <gtk/gtk.h>           // for gtk_grid_attach, GtkWidget, gtk_toggle...
+#include <stdio.h>             // for NULL
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "new_menu.h"          // for sub_menu
+#include "radio.h"             // for set_filter_type, receiver
+#include "receiver.h"          // for RECEIVER
 
 static GtkWidget *parent_window=NULL;
 
diff --git a/fft_menu.h b/fft_menu.h
index 0e4841c..c4f0f32 100644
--- a/fft_menu.h
+++ b/fft_menu.h
@@ -16,5 +16,6 @@
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
+#include <gtk/gtk.h>  // for GtkWidget
 
 void fft_menu(GtkWidget *parent);
diff --git a/filter.c b/filter.c
index 6bfba8a..ad2c411 100644
--- a/filter.c
+++ b/filter.c
@@ -17,16 +17,15 @@
 *
 */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdbool.h>
-
-#include "sliders.h"
 #include "filter.h"
-#include "receiver.h"
-#include "vfo.h"
-#include "radio.h"
-#include "property.h"
+#include <glib.h>      // for gint
+#include <stdio.h>     // for sprintf, fprintf, stderr
+#include <stdlib.h>    // for atoi
+#include "property.h"  // for getProperty, setProperty
+#include "radio.h"     // for receiver
+#include "receiver.h"  // for RECEIVER
+#include "sliders.h"   // for set_filter_shift, set_filter_width
+#include "vfo.h"       // for _vfo, vfo, vfo_filter_changed
 
 FILTER filterLSB[FILTERS]={
     {-5150,-150,"5.0k"},
diff --git a/filter_menu.c b/filter_menu.c
index 7c7b6df..cf1b923 100644
--- a/filter_menu.c
+++ b/filter_menu.c
@@ -14,25 +14,23 @@
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
-
-#include <gtk/gtk.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "new_menu.h"
 #include "filter_menu.h"
-#include "band.h"
-#include "bandstack.h"
-#include "filter.h"
-#include "mode.h"
-#include "radio.h"
-#include "receiver.h"
-#include "vfo.h"
-#include "button_text.h"
-#include "ext.h"
+#include <gdk/gdk.h>           // for GdkRGBA, GdkEvent, GdkEventButton
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for gpointer, gboolean, FALSE, TRUE, g_idl...
+#include <glib/gtypes.h>       // for GPOINTER_TO_UINT
+#include <gtk/gtk.h>           // for gtk_grid_attach, GtkWidget, gtk_button...
+#include <stdio.h>             // for NULL, sprintf
+#include "button_text.h"       // for set_button_text_color
+#include "ext.h"               // for ext_vfo_update
+#include "filter.h"            // for FILTER, filters, FILTERS
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "mode.h"              // for modeCWL, modeCWU, modeFMN
+#include "new_menu.h"          // for sub_menu, NO_MENU, active_menu
+#include "radio.h"             // for active_receiver, transmitter
+#include "receiver.h"          // for RECEIVER, set_filter, set_deviation
+#include "transmitter.h"       // for tx_set_filter, transmitter_set_deviation
+#include "vfo.h"               // for _vfo, vfo, vfo_filter_changed
 
 static GtkWidget *parent_window=NULL;
 
diff --git a/filter_menu.h b/filter_menu.h
index 057532a..f6bedc0 100644
--- a/filter_menu.h
+++ b/filter_menu.h
@@ -16,6 +16,7 @@
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
+#include <gtk/gtk.h>  // for GtkWidget
 
 extern void filter_menu(GtkWidget *parent);
 extern int filter_select(void *data);
diff --git a/gpio.c b/gpio.c
index 2164e28..97931bb 100644
--- a/gpio.c
+++ b/gpio.c
@@ -21,63 +21,38 @@
 // Note that all pin numbers are now the Broadcom GPIO
 
 
-#include <gtk/gtk.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdint.h>
-#include <fcntl.h>
-#include <poll.h>
-#include <sched.h>
-
-#ifdef GPIO
-#include <gpiod.h>
-#include <linux/i2c-dev.h>
-#include <i2c/smbus.h>
-#include <sys/ioctl.h>
-#endif
-
-#include "band.h"
-#include "channel.h"
-#include "discovered.h"
-#include "mode.h"
-#include "filter.h"
-#include "bandstack.h"
-#include "toolbar.h"
-#include "radio.h"
-#include "toolbar.h"
-#include "main.h"
-#include "property.h"
-#include "vfo.h"
-#include "wdsp.h"
-#include "new_menu.h"
-#include "encoder_menu.h"
-#include "diversity_menu.h"
-#include "actions.h"
 #include "gpio.h"
-#include "i2c.h"
-#include "ext.h"
-#include "sliders.h"
-#include "new_protocol.h"
-#include "zoompan.h"
-#ifdef LOCALCW
-#include "iambic.h"
-#include "log.h"
+#include <errno.h>     // for errno
+#include <gpiod.h>     // for gpiod_line_request_config, gpiod_chip_close
+#include <sched.h>     // for timespec
+#include <stdint.h>    // for uint64_t, uint32_t
+#include <stdio.h>     // for sprintf, NULL
+#include <stdlib.h>    // for atoi, exit
+#include <time.h>      // for clock_gettime, CLOCK_MONOTONIC_RAW
+#include <unistd.h>    // for usleep
+#include "actions.h"   // for NO_ACTION, MOX, FUNCTION, MENU_FREQUENCY, PROC...
+#include "i2c.h"       // for i2c_init, i2c_interrupt
+#include "iambic.h"    // for keyer_event
+#include "log.h"       // for log_trace, log_error, log_debug
+#include "main.h"      // for controller, NO_CONTROLLER, CONTROLLER2_V1, CON...
+#include "property.h"  // for setProperty, getProperty, clearProperties, loa...
+#include "radio.h"     // for vfo_encoder_divisor
+#include "toolbar.h"   // for function, update_toolbar_labels
 
 //
 // Broadcom pins #9, 10, 11 are not used
 // by Controller1 and Controller2_V1
 // (and keep #2,3 reserved for I2C extensions)
 //
+#ifdef LOCALCW
+
 int CWL_BUTTON=17; // was 9
 int CWR_BUTTON=21;  //was 11
 int SIDETONE_GPIO=10;
 int ENABLE_GPIO_SIDETONE=0;
 int ENABLE_CW_BUTTONS=1;
 int CW_ACTIVE_LOW=1;
+
 #endif
 
 #ifdef PTT
diff --git a/gpio.h b/gpio.h
index 2276f81..2c93693 100644
--- a/gpio.h
+++ b/gpio.h
@@ -20,6 +20,9 @@
 #ifndef _GPIO_H
 #define _GPIO_H
 
+#include <time.h>      // for clock_gettime, CLOCK_MONOTONIC_RAW
+#include <glib.h>
+
 #define MAX_ENCODERS 5
 #define MAX_SWITCHES 16
 #define MAX_FUNCTIONS 6
diff --git a/gpio.props b/gpio.props
new file mode 100644
index 0000000..7abd17e
--- /dev/null
+++ b/gpio.props
@@ -0,0 +1,345 @@
+property_version=3.00
+switches[5,15].switch_address=0
+switches[5,15].switch_pullup=0
+switches[5,15].switch_enabled=0
+switches[5,14].switch_address=0
+switches[5,14].switch_pullup=0
+switches[5,14].switch_enabled=0
+switches[5,13].switch_address=0
+switches[5,13].switch_pullup=0
+switches[5,13].switch_enabled=0
+switches[5,12].switch_address=0
+switches[5,12].switch_pullup=0
+switches[5,12].switch_enabled=0
+switches[5,11].switch_address=0
+switches[5,11].switch_pullup=0
+switches[5,11].switch_enabled=0
+switches[5,10].switch_address=0
+switches[5,10].switch_pullup=0
+switches[5,10].switch_enabled=0
+switches[5,9].switch_address=0
+switches[5,9].switch_pullup=0
+switches[5,9].switch_enabled=0
+switches[5,8].switch_address=0
+switches[5,8].switch_pullup=0
+switches[5,8].switch_enabled=0
+switches[5,7].switch_address=22
+switches[5,7].switch_pullup=1
+switches[5,7].switch_enabled=1
+switches[5,6].switch_address=23
+switches[5,6].switch_pullup=1
+switches[5,6].switch_enabled=1
+switches[5,5].switch_address=24
+switches[5,5].switch_pullup=1
+switches[5,5].switch_enabled=1
+switches[5,4].switch_address=5
+switches[5,4].switch_pullup=1
+switches[5,4].switch_enabled=1
+switches[5,3].switch_address=6
+switches[5,3].switch_pullup=1
+switches[5,3].switch_enabled=1
+switches[5,2].switch_address=12
+switches[5,2].switch_pullup=1
+switches[5,2].switch_enabled=1
+switches[5,1].switch_address=13
+switches[5,1].switch_pullup=1
+switches[5,1].switch_enabled=1
+switches[5,0].switch_address=27
+switches[5,0].switch_pullup=1
+switches[5,0].switch_enabled=1
+switches[4,15].switch_address=0
+switches[4,15].switch_pullup=0
+switches[4,15].switch_enabled=0
+switches[4,14].switch_address=0
+switches[4,14].switch_pullup=0
+switches[4,14].switch_enabled=0
+switches[4,13].switch_address=0
+switches[4,13].switch_pullup=0
+switches[4,13].switch_enabled=0
+switches[4,12].switch_address=0
+switches[4,12].switch_pullup=0
+switches[4,12].switch_enabled=0
+switches[4,11].switch_address=0
+switches[4,11].switch_pullup=0
+switches[4,11].switch_enabled=0
+switches[4,10].switch_address=0
+switches[4,10].switch_pullup=0
+switches[4,10].switch_enabled=0
+switches[4,9].switch_address=0
+switches[4,9].switch_pullup=0
+switches[4,9].switch_enabled=0
+switches[4,8].switch_address=0
+switches[4,8].switch_pullup=0
+switches[4,8].switch_enabled=0
+switches[4,7].switch_address=22
+switches[4,7].switch_pullup=1
+switches[4,7].switch_enabled=1
+switches[4,6].switch_address=23
+switches[4,6].switch_pullup=1
+switches[4,6].switch_enabled=1
+switches[4,5].switch_address=24
+switches[4,5].switch_pullup=1
+switches[4,5].switch_enabled=1
+switches[4,4].switch_address=5
+switches[4,4].switch_pullup=1
+switches[4,4].switch_enabled=1
+switches[4,3].switch_address=6
+switches[4,3].switch_pullup=1
+switches[4,3].switch_enabled=1
+switches[4,2].switch_address=12
+switches[4,2].switch_pullup=1
+switches[4,2].switch_enabled=1
+switches[4,1].switch_address=13
+switches[4,1].switch_pullup=1
+switches[4,1].switch_enabled=1
+switches[4,0].switch_address=27
+switches[4,0].switch_pullup=1
+switches[4,0].switch_enabled=1
+switches[3,15].switch_address=0
+switches[3,15].switch_pullup=0
+switches[3,15].switch_enabled=0
+switches[3,14].switch_address=0
+switches[3,14].switch_pullup=0
+switches[3,14].switch_enabled=0
+switches[3,13].switch_address=0
+switches[3,13].switch_pullup=0
+switches[3,13].switch_enabled=0
+switches[3,12].switch_address=0
+switches[3,12].switch_pullup=0
+switches[3,12].switch_enabled=0
+switches[3,11].switch_address=0
+switches[3,11].switch_pullup=0
+switches[3,11].switch_enabled=0
+switches[3,10].switch_address=0
+switches[3,10].switch_pullup=0
+switches[3,10].switch_enabled=0
+switches[3,9].switch_address=0
+switches[3,9].switch_pullup=0
+switches[3,9].switch_enabled=0
+switches[3,8].switch_address=0
+switches[3,8].switch_pullup=0
+switches[3,8].switch_enabled=0
+switches[3,7].switch_address=22
+switches[3,7].switch_pullup=1
+switches[3,7].switch_enabled=1
+switches[3,6].switch_address=23
+switches[3,6].switch_pullup=1
+switches[3,6].switch_enabled=1
+switches[3,5].switch_address=24
+switches[3,5].switch_pullup=1
+switches[3,5].switch_enabled=1
+switches[3,4].switch_address=5
+switches[3,4].switch_pullup=1
+switches[3,4].switch_enabled=1
+switches[3,3].switch_address=6
+switches[3,3].switch_pullup=1
+switches[3,3].switch_enabled=1
+switches[3,2].switch_address=12
+switches[3,2].switch_pullup=1
+switches[3,2].switch_enabled=1
+switches[3,1].switch_address=13
+switches[3,1].switch_pullup=1
+switches[3,1].switch_enabled=1
+switches[3,0].switch_address=27
+switches[3,0].switch_pullup=1
+switches[3,0].switch_enabled=1
+switches[2,15].switch_address=0
+switches[2,15].switch_pullup=0
+switches[2,15].switch_enabled=0
+switches[2,14].switch_address=0
+switches[2,14].switch_pullup=0
+switches[2,14].switch_enabled=0
+switches[2,13].switch_address=0
+switches[2,13].switch_pullup=0
+switches[2,13].switch_enabled=0
+switches[2,12].switch_address=0
+switches[2,12].switch_pullup=0
+switches[2,12].switch_enabled=0
+switches[2,11].switch_address=0
+switches[2,11].switch_pullup=0
+switches[2,11].switch_enabled=0
+switches[2,10].switch_address=0
+switches[2,10].switch_pullup=0
+switches[2,10].switch_enabled=0
+switches[2,9].switch_address=0
+switches[2,9].switch_pullup=0
+switches[2,9].switch_enabled=0
+switches[2,8].switch_address=0
+switches[2,8].switch_pullup=0
+switches[2,8].switch_enabled=0
+switches[2,7].switch_address=22
+switches[2,7].switch_pullup=1
+switches[2,7].switch_enabled=1
+switches[2,6].switch_address=23
+switches[2,6].switch_pullup=1
+switches[2,6].switch_enabled=1
+switches[2,5].switch_address=24
+switches[2,5].switch_pullup=1
+switches[2,5].switch_enabled=1
+switches[2,4].switch_address=5
+switches[2,4].switch_pullup=1
+switches[2,4].switch_enabled=1
+switches[2,3].switch_address=6
+switches[2,3].switch_pullup=1
+switches[2,3].switch_enabled=1
+switches[2,2].switch_address=12
+switches[2,2].switch_pullup=1
+switches[2,2].switch_enabled=1
+switches[2,1].switch_address=13
+switches[2,1].switch_pullup=1
+switches[2,1].switch_enabled=1
+switches[2,0].switch_address=27
+switches[2,0].switch_pullup=1
+switches[2,0].switch_enabled=1
+switches[1,15].switch_address=0
+switches[1,15].switch_pullup=0
+switches[1,15].switch_enabled=0
+switches[1,14].switch_address=0
+switches[1,14].switch_pullup=0
+switches[1,14].switch_enabled=0
+switches[1,13].switch_address=0
+switches[1,13].switch_pullup=0
+switches[1,13].switch_enabled=0
+switches[1,12].switch_address=0
+switches[1,12].switch_pullup=0
+switches[1,12].switch_enabled=0
+switches[1,11].switch_address=0
+switches[1,11].switch_pullup=0
+switches[1,11].switch_enabled=0
+switches[1,10].switch_address=0
+switches[1,10].switch_pullup=0
+switches[1,10].switch_enabled=0
+switches[1,9].switch_address=0
+switches[1,9].switch_pullup=0
+switches[1,9].switch_enabled=0
+switches[1,8].switch_address=0
+switches[1,8].switch_pullup=0
+switches[1,8].switch_enabled=0
+switches[1,7].switch_address=22
+switches[1,7].switch_pullup=1
+switches[1,7].switch_enabled=1
+switches[1,6].switch_address=23
+switches[1,6].switch_pullup=1
+switches[1,6].switch_enabled=1
+switches[1,5].switch_address=24
+switches[1,5].switch_pullup=1
+switches[1,5].switch_enabled=1
+switches[1,4].switch_address=5
+switches[1,4].switch_pullup=1
+switches[1,4].switch_enabled=1
+switches[1,3].switch_address=6
+switches[1,3].switch_pullup=1
+switches[1,3].switch_enabled=1
+switches[1,2].switch_address=12
+switches[1,2].switch_pullup=1
+switches[1,2].switch_enabled=1
+switches[1,1].switch_address=13
+switches[1,1].switch_pullup=1
+switches[1,1].switch_enabled=1
+switches[1,0].switch_address=27
+switches[1,0].switch_pullup=1
+switches[1,0].switch_enabled=1
+switches[0,15].switch_address=0
+switches[0,15].switch_pullup=0
+switches[0,15].switch_enabled=0
+switches[0,14].switch_address=0
+switches[0,14].switch_pullup=0
+switches[0,14].switch_enabled=0
+switches[0,13].switch_address=0
+switches[0,13].switch_pullup=0
+switches[0,13].switch_enabled=0
+switches[0,12].switch_address=0
+switches[0,12].switch_pullup=0
+switches[0,12].switch_enabled=0
+switches[0,11].switch_address=0
+switches[0,11].switch_pullup=0
+switches[0,11].switch_enabled=0
+switches[0,10].switch_address=0
+switches[0,10].switch_pullup=0
+switches[0,10].switch_enabled=0
+switches[0,9].switch_address=0
+switches[0,9].switch_pullup=0
+switches[0,9].switch_enabled=0
+switches[0,8].switch_address=0
+switches[0,8].switch_pullup=0
+switches[0,8].switch_enabled=0
+switches[0,7].switch_address=22
+switches[0,7].switch_pullup=1
+switches[0,7].switch_enabled=1
+switches[0,6].switch_address=23
+switches[0,6].switch_pullup=1
+switches[0,6].switch_enabled=1
+switches[0,5].switch_address=24
+switches[0,5].switch_pullup=1
+switches[0,5].switch_enabled=1
+switches[0,4].switch_address=5
+switches[0,4].switch_pullup=1
+switches[0,4].switch_enabled=1
+switches[0,3].switch_address=6
+switches[0,3].switch_pullup=1
+switches[0,3].switch_enabled=1
+switches[0,2].switch_address=12
+switches[0,2].switch_pullup=1
+switches[0,2].switch_enabled=1
+switches[0,1].switch_address=13
+switches[0,1].switch_pullup=1
+switches[0,1].switch_enabled=1
+switches[0,0].switch_address=27
+switches[0,0].switch_pullup=1
+switches[0,0].switch_enabled=1
+encoders[4].switch_address=0
+encoders[4].switch_pullup=1
+encoders[4].switch_enabled=0
+encoders[4].top_encoder_address_b=0
+encoders[4].top_encoder_address_a=0
+encoders[4].top_encoder_pullup=1
+encoders[4].top_encoder_enabled=0
+encoders[4].bottom_encoder_address_b=0
+encoders[4].bottom_encoder_address_a=0
+encoders[4].bottom_encoder_pullup=1
+encoders[4].bottom_encoder_enabled=0
+encoders[3].switch_address=0
+encoders[3].switch_pullup=1
+encoders[3].switch_enabled=0
+encoders[3].top_encoder_address_b=0
+encoders[3].top_encoder_address_a=0
+encoders[3].top_encoder_pullup=1
+encoders[3].top_encoder_enabled=0
+encoders[3].bottom_encoder_address_b=17
+encoders[3].bottom_encoder_address_a=18
+encoders[3].bottom_encoder_pullup=1
+encoders[3].bottom_encoder_enabled=1
+encoders[2].switch_address=7
+encoders[2].switch_pullup=1
+encoders[2].switch_enabled=1
+encoders[2].top_encoder_address_b=0
+encoders[2].top_encoder_address_a=0
+encoders[2].top_encoder_pullup=1
+encoders[2].top_encoder_enabled=0
+encoders[2].bottom_encoder_address_b=21
+encoders[2].bottom_encoder_address_a=4
+encoders[2].bottom_encoder_pullup=1
+encoders[2].bottom_encoder_enabled=1
+encoders[1].switch_address=8
+encoders[1].switch_pullup=1
+encoders[1].switch_enabled=1
+encoders[1].top_encoder_address_b=0
+encoders[1].top_encoder_address_a=0
+encoders[1].top_encoder_pullup=1
+encoders[1].top_encoder_enabled=0
+encoders[1].bottom_encoder_address_b=19
+encoders[1].bottom_encoder_address_a=16
+encoders[1].bottom_encoder_pullup=1
+encoders[1].bottom_encoder_enabled=1
+encoders[0].switch_address=25
+encoders[0].switch_pullup=1
+encoders[0].switch_enabled=1
+encoders[0].top_encoder_address_b=0
+encoders[0].top_encoder_address_a=0
+encoders[0].top_encoder_pullup=1
+encoders[0].top_encoder_enabled=0
+encoders[0].bottom_encoder_address_b=26
+encoders[0].bottom_encoder_address_a=20
+encoders[0].bottom_encoder_pullup=1
+encoders[0].bottom_encoder_enabled=1
+controller=1
diff --git a/i2c.c b/i2c.c
index 5c8353a..93d972b 100644
--- a/i2c.c
+++ b/i2c.c
@@ -1,26 +1,14 @@
 #ifdef GPIO
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <linux/i2c-dev.h>
-#include <i2c/smbus.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <stdbool.h>
-#include <gtk/gtk.h>
-
 #include "i2c.h"
-#include "actions.h"
-#include "gpio.h"
-#include "band.h"
-#include "band_menu.h"
-#include "bandstack.h"
-#include "radio.h"
-#include "toolbar.h"
-#include "vfo.h"
-#include "ext.h"
+#include <errno.h>          // for errno
+#include <fcntl.h>          // for open, O_RDWR
+#include <glib.h>           // for g_print, g_strerror, g_malloc, g_idle_add
+#include <i2c/smbus.h>      // for i2c_smbus_read_word_data, i2c_smbus_write...
+#include <linux/i2c-dev.h>  // for I2C_SLAVE
+#include <stdio.h>          // for fprintf, stderr
+#include <sys/ioctl.h>      // for ioctl
+#include "actions.h"        // for PROCESS_ACTION, process_action, PRESSED
+#include "gpio.h"           // for SWITCH, switches
 
 char *i2c_device="/dev/i2c-1";
 unsigned int i2c_address_1=0X20;
diff --git a/led.c b/led.c
index 98525ba..e221c72 100644
--- a/led.c
+++ b/led.c
@@ -17,7 +17,13 @@
 *
 */
 
-#include <gtk/gtk.h>
+#include <gdk/gdk.h>           // for GdkRGBA
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for gpointer, FALSE, gboolean
+#include <gtk/gtk.h>           // for GtkWidget, gtk_drawing_area_new, gtk_w...
+#include <stdio.h>             // for fprintf, stderr
+#include "cairo.h"             // for cairo_paint, cairo_set_source_rgb, cai...
+#include "gobject/gclosure.h"  // for G_CALLBACK
 
 static gboolean draw_led_cb (GtkWidget *widget, cairo_t *cr, gpointer data) {
   GdkRGBA *color=(GdkRGBA *)data;
diff --git a/main.c b/main.c
index 68ebbbd..97fc91b 100644
--- a/main.c
+++ b/main.c
@@ -23,45 +23,31 @@
 #define MAX_DISPLAY_WIDTH 1024 // edit
 #define MAX_DISPLAY_HEIGHT 600 // edit
 
-#include <arpa/inet.h>
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-#include <math.h>
-#include <netinet/in.h>
-#include <semaphore.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <stdbool.h>
-
-#include "actions.h"
-#include "audio.h"
-#include "band.h"
-#include "bandstack.h"
-#include "channel.h"
-#include "configure.h"
-#include "discovered.h"
 #include "main.h"
-#ifdef GPIO
-#include "gpio.h"
-#endif
-#include "button_text.h"
-#include "new_menu.h"
-#include "radio.h"
-#include "wdsp.h"
-#ifdef I2C
-#include "i2c.h"
-#endif
-#include "discovery.h"
-#include "new_protocol.h"
-#include "old_protocol.h"
-#include "css.h"
-#include "ext.h"
-#include "vfo.h"
-
-#include "log.h"
+#include <gdk/gdk.h>           // for gdk_cursor_new, GdkEventKey, gdk_scree...
+#include <gio/gio.h>           // for g_application_run, G_APPLICATION, G_AP...
+#include <glib-object.h>       // for g_object_unref, g_signal_connect
+#include <gtk/gtk.h>           // for GtkWidget, gtk_events_pending, gtk_gri...
+#include <pthread.h>           // for pthread_create, pthread_t
+#include <stdbool.h>           // for bool
+#include <stdio.h>             // for perror
+#include <string.h>            // for strcpy, strlen
+#include <unistd.h>            // for _exit, usleep, getcwd
+#include "audio.h"             // for audio_get_cards
+#include "band.h"              // for canTransmit
+#include "css.h"               // for load_css
+#include "discovered.h"        // for NEW_PROTOCOL, ORIGINAL_PROTOCOL
+#include "ext.h"               // for ext_discovery, ext_vfo_update
+#include "gdk/gdkkeysyms.h"    // for GDK_KEY_d, GDK_KEY_space, GDK_KEY_u
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "gpio.h"              // for gpio_close
+#include "log.h"               // for log_debug, log_warn
+#include "new_protocol.h"      // for setMox, getMox, getTune, new_protocol_...
+#include "old_protocol.h"      // for old_protocol_stop
+#include "radio.h"             // for radioSaveState, radio, step, protocol
+#include "transmitter.h"       // for transmitter_set_out_of_band
+#include "vfo.h"               // for vfo_move
+#include "wdsp.h"              // for WDSPwisdom, wisdom_get_status
 
 struct utsname unameData;
 
diff --git a/main.h b/main.h
index 5b540dd..b6a1f65 100644
--- a/main.h
+++ b/main.h
@@ -20,7 +20,12 @@
 #ifndef _MAIN_H
 #define _MAIN_H
 
-#include <sys/utsname.h>
+#include <gdk/gdk.h>      // for GdkEventKey
+#include <glib.h>         // for gpointer
+#include <gtk/gtk.h>      // for GtkWidget
+#include <stdbool.h>      // for bool
+#include <sys/utsname.h>  // for utsname
+
 extern struct utsname unameData;
 
 enum {
diff --git a/memory.c b/memory.c
index 5196719..871319f 100644
--- a/memory.c
+++ b/memory.c
@@ -17,9 +17,9 @@
 *
 */
 
-#include <sys/resource.h>
-#include <stdio.h>
-#include "log.h"
+#include <bits/types/struct_rusage.h>  // for rusage, rusage::(anonymous)
+#include <sys/resource.h>              // for getrusage, RUSAGE_SELF
+#include "log.h"                       // for log_trace
 
 void show_memory(char *title) {
   struct rusage r_usage;
diff --git a/meter.c b/meter.c
index 67dd066..b1aa7ea 100644
--- a/meter.c
+++ b/meter.c
@@ -17,23 +17,21 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <gdk/gdk.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <math.h>
-#include <stdbool.h>
-
-#include "receiver.h"
 #include "meter.h"
-#include "radio.h"
-#include "wdsp.h"
-#include "radio.h"
-#include "mode.h"
-#include "vox.h"
-#include "new_menu.h"
-#include "vfo.h"
+#include <gdk/gdk.h>           // for gdk_window_create_similar_surface, GDK...
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for gboolean, gpointer, TRUE, FALSE
+#include <gtk/gtk.h>           // for GtkWidget, gtk_drawing_area_new, gtk_w...
+#include <math.h>              // for M_PI, fmax, sqrt
+#include <stdio.h>             // for sprintf, NULL
+#include "adc.h"               // for ADC
+#include "cairo.h"             // for cairo_move_to, cairo_line_to, cairo_se...
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "new_menu.h"          // for start_meter
+#include "radio.h"             // for adc, filter_board, vox_threshold, vox_...
+#include "receiver.h"          // for RECEIVER
+#include "vfo.h"               // for _vfo, vfo
+#include "vox.h"               // for vox_get_peak
 
 static GtkWidget *parent_window;
 
diff --git a/meter.h b/meter.h
index 7c3bfd2..08ccfa7 100644
--- a/meter.h
+++ b/meter.h
@@ -20,7 +20,8 @@
 #ifndef _METER_H
 #define _METER_H
 
-#include <gtk/gtk.h>
+#include <gtk/gtk.h>   // for GtkWidget
+#include "receiver.h"  // for RECEIVER
 
 #define SMETER 0
 #define POWER 1
diff --git a/meter_menu.c b/meter_menu.c
index f018031..b1f21bf 100644
--- a/meter_menu.c
+++ b/meter_menu.c
@@ -17,20 +17,17 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <string.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdbool.h>
-
-#include <wdsp.h>
-
-#include "new_menu.h"
-#include "receiver.h"
 #include "meter_menu.h"
-#include "meter.h"
-#include "radio.h"
+#include <gdk/gdk.h>           // for GdkRGBA, GdkEvent, GdkEventButton
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for gpointer, TRUE, gboolean, FALSE
+#include <glib/gtypes.h>       // for GINT_TO_POINTER, GPOINTER_TO_UINT
+#include <gtk/gtk.h>           // for gtk_grid_attach, gtk_toggle_button_set...
+#include <stdlib.h>            // for NULL
+#include <wdsp.h>              // for RXA_S_AV, RXA_S_PK, TXA_ALC_AV, TXA_AL...
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "new_menu.h"          // for sub_menu
+#include "radio.h"             // for alc, smeter, analog_meter, with_gain
 
 static GtkWidget *parent_window=NULL;
 static GtkWidget *dialog=NULL;
diff --git a/meter_menu.h b/meter_menu.h
index cac8ac4..d9a1c86 100644
--- a/meter_menu.h
+++ b/meter_menu.h
@@ -16,5 +16,6 @@
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
+#include <gtk/gtk.h>  // for GtkWidget
 
 void meter_menu (GtkWidget *parent);
diff --git a/mode_menu.c b/mode_menu.c
index bd78dae..d03c2f4 100644
--- a/mode_menu.c
+++ b/mode_menu.c
@@ -17,23 +17,19 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "new_menu.h"
-#include "band_menu.h"
-#include "band.h"
-#include "bandstack.h"
-#include "filter.h"
-#include "mode.h"
-#include "radio.h"
-#include "receiver.h"
-#include "vfo.h"
-#include "button_text.h"
+#include <gdk/gdk.h>           // for GdkRGBA, GdkEvent, GdkEventButton
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for gpointer, TRUE, gboolean, FALSE
+#include <glib/gtypes.h>       // for GPOINTER_TO_UINT
+#include <gtk/gtk.h>           // for GtkWidget, GTK_GRID, gtk_button_new_wi...
+#include <stdio.h>             // for NULL, sprintf
+#include "button_text.h"       // for set_button_text_color
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "mode.h"              // for MODES, mode_string
+#include "new_menu.h"          // for sub_menu, NO_MENU, active_menu
+#include "radio.h"             // for active_receiver
+#include "receiver.h"          // for RECEIVER
+#include "vfo.h"               // for vfo_mode_changed, _vfo, vfo
 
 static GtkWidget *parent_window=NULL;
 
diff --git a/nb_menu.c b/nb_menu.c
index 3325f5b..125bc3d 100644
--- a/nb_menu.c
+++ b/nb_menu.c
@@ -18,19 +18,16 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <semaphore.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "new_menu.h"
-#include "noise_menu.h"
-#include "radio.h"
-
-#include <wdsp.h>
+#include <gdk/gdk.h>           // for GdkRGBA, GdkEvent, GdkEventButton
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for gpointer, gboolean, FALSE, TRUE
+#include <gtk/gtk.h>           // for gtk_grid_attach, gtk_widget_show, GtkW...
+#include <stdio.h>             // for NULL
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "new_menu.h"          // for sub_menu
+#include "noise_menu.h"        // for update_nb
+#include "radio.h"             // for active_receiver
+#include "receiver.h"          // for RECEIVER
 
 static GtkWidget *parent_window = NULL;
 static GtkWidget *dialog = NULL;
diff --git a/nb_menu.h b/nb_menu.h
index a866d98..d3ce165 100644
--- a/nb_menu.h
+++ b/nb_menu.h
@@ -17,6 +17,7 @@
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
+#include <gtk/gtk.h>
 
 extern void nb_menu(GtkWidget *parent);
 
diff --git a/new_discovery.c b/new_discovery.c
index 1d860c9..ec43fac 100644
--- a/new_discovery.c
+++ b/new_discovery.c
@@ -17,25 +17,18 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <net/if_arp.h>
-#include <net/if.h>
-#include <netinet/in.h>
-#include <ifaddrs.h>
-#include <string.h>
-#include <errno.h>
-
-#include "discovered.h"
-//#include "discovery.h"
-
+#include <arpa/inet.h>   // for inet_ntoa
+#include <glib.h>        // for gpointer, g_main_context_iteration, g_thread...
+#include <ifaddrs.h>     // for ifaddrs, freeifaddrs, getifaddrs
+#include <net/if.h>      // for IFF_RUNNING, IFF_UP
+#include <netinet/in.h>  // for sockaddr_in, in_addr, htons, INADDR_BROADCAST
+#include <stdio.h>       // for fprintf, perror, stderr, NULL
+#include <stdlib.h>      // for exit
+#include <string.h>      // for strcpy, memcpy
+#include <sys/socket.h>  // for setsockopt, SOL_SOCKET, AF_INET, bind, recvfrom
+#include <sys/time.h>    // for timeval
+#include <unistd.h>      // for close
+#include "discovered.h"  // for DISCOVERED, discovered, devices, _DISCOVERED...
 
 static char interface_name[64];
 static struct sockaddr_in interface_addr={0};
diff --git a/new_menu.c b/new_menu.c
index 38be1ae..e86a4c9 100644
--- a/new_menu.c
+++ b/new_menu.c
@@ -17,58 +17,47 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <semaphore.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "audio.h"
 #include "new_menu.h"
-#include "about_menu.h"
-#include "exit_menu.h"
-#include "radio_menu.h"
-#include "rx_menu.h"
-#include "ant_menu.h"
-#include "display_menu.h"
-#include "dsp_menu.h"
-#include "pa_menu.h"
-#include "rigctl_menu.h"
-#include "oc_menu.h"
-#include "cw_menu.h"
-#include "nb_menu.h"
-#include "store_menu.h"
-#include "xvtr_menu.h"
-#include "equalizer_menu.h"
-#include "radio.h"
-#include "step_menu.h"
-#include "meter_menu.h"
-#include "band_menu.h"
-#include "bandstack_menu.h"
-#include "mode_menu.h"
-#include "filter_menu.h"
-#include "noise_menu.h"
-#include "agc_menu.h"
-#include "vox_menu.h"
-#include "diversity_menu.h"
-#include "tx_menu.h"
-#include "ps_menu.h"
-#include "encoder_menu.h"
-#include "switch_menu.h"
-#include "toolbar_menu.h"
-#include "vfo_menu.h"
-#include "fft_menu.h"
-#include "main.h"
-#include "actions.h"
-#include "gpio.h"
-#include "old_protocol.h"
-#include "new_protocol.h"
-#ifdef CLIENT_SERVER
-#include "server_menu.h"
-#endif
-#ifdef MIDI
-#include "midi_menu.h"
-#endif
+#include <gdk/gdk.h>           // for GdkEventButton, GdkRGBA, GdkEvent
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for TRUE, gboolean, gpointer, FALSE
+#include <gtk/gtk.h>           // for gtk_button_new_with_label, gtk_grid_at...
+#include <stdio.h>             // for NULL
+#include "about_menu.h"        // for about_menu
+#include "agc_menu.h"          // for agc_menu
+#include "ant_menu.h"          // for ant_menu
+#include "band_menu.h"         // for band_menu
+#include "bandstack_menu.h"    // for bandstack_menu
+#include "cw_menu.h"           // for cw_menu
+#include "discovered.h"        // for NEW_PROTOCOL, ORIGINAL_PROTOCOL
+#include "display_menu.h"      // for display_menu
+#include "diversity_menu.h"    // for diversity_menu
+#include "dsp_menu.h"          // for dsp_menu
+#include "encoder_menu.h"      // for encoder_menu
+#include "equalizer_menu.h"    // for equalizer_menu
+#include "exit_menu.h"         // for exit_menu
+#include "fft_menu.h"          // for fft_menu
+#include "filter_menu.h"       // for filter_menu
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "main.h"              // for top_window, CONTROLLER1, CONTROLLER2_V1
+#include "meter_menu.h"        // for meter_menu
+#include "mode_menu.h"         // for mode_menu
+#include "nb_menu.h"           // for nb_menu
+#include "noise_menu.h"        // for noise_menu
+#include "oc_menu.h"           // for oc_menu
+#include "pa_menu.h"           // for pa_menu
+#include "radio.h"             // for can_transmit, protocol, RECEIVERS, n_adc
+#include "radio_menu.h"        // for radio_menu
+#include "rigctl_menu.h"       // for rigctl_menu
+#include "rx_menu.h"           // for rx_menu
+#include "step_menu.h"         // for step_menu
+#include "store_menu.h"        // for store_menu
+#include "switch_menu.h"       // for switch_menu
+#include "toolbar_menu.h"      // for toolbar_menu
+#include "tx_menu.h"           // for tx_menu
+#include "vfo_menu.h"          // for vfo_menu
+#include "vox_menu.h"          // for vox_menu
+#include "xvtr_menu.h"         // for xvtr_menu
 
 static GtkWidget *dialog=NULL;
 
diff --git a/new_menu.h b/new_menu.h
index 977c564..a4d728c 100644
--- a/new_menu.h
+++ b/new_menu.h
@@ -1,3 +1,5 @@
+#include <gtk/gtk.h>
+
 extern GtkWidget *sub_menu;
 
 extern void new_menu();
diff --git a/new_protocol.c b/new_protocol.c
index 755874f..4b4c985 100644
--- a/new_protocol.c
+++ b/new_protocol.c
@@ -20,47 +20,34 @@
 
 //#define ECHO_MIC
 
-#include <gtk/gtk.h>
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <net/if_arp.h>
-#include <net/if.h>
-#include <ifaddrs.h>
-#include <semaphore.h>
-#include <math.h>
-#include <sys/select.h>
-#include <stdbool.h>
-
-#include <wdsp.h>
-
-#include "alex.h"
-#include "audio.h"
-#include "band.h"
 #include "new_protocol.h"
-#include "channel.h"
-#include "discovered.h"
-#include "mode.h"
-#include "filter.h"
-#include "radio.h"
-#include "receiver.h"
-#include "transmitter.h"
-#include "signal.h"
-#include "vfo.h"
-#include "toolbar.h"
-#include "vox.h"
-#include "ext.h"
-#include "iambic.h"
+#include <arpa/inet.h>    // for inet_ntoa
+#include <errno.h>        // for errno
+#include <glib.h>         // for g_print, gpointer, g_thread_new, GThread
+#include <glib/gtypes.h>  // for GINT_TO_POINTER, GPOINTER_TO_INT
+#include <math.h>         // for sqrt
+#include <netinet/in.h>   // for sockaddr_in, htons, ntohs, IPPROTO_UDP
+#include <pthread.h>      // for pthread_mutex_lock, pthread_mutex_unlock
+#include <semaphore.h>    // for sem_init, sem_post, sem_wait, sem_t
+#include <stdio.h>        // for NULL
+#include <stdlib.h>       // for exit, free, malloc, abort
+#include <string.h>       // for memset, memcpy
+#include <sys/select.h>   // for select, FD_SET, FD_ZERO, fd_set
+#include <sys/socket.h>   // for sendto, recvfrom, setsockopt, bind, socket
+#include <sys/time.h>     // for timeval, gettimeofday
+#include <unistd.h>       // for usleep, close
+#include "adc.h"          // for ADC
+#include "alex.h"         // for ALEX_RX_ANTENNA_BYPASS, ALEX_RX_ANTENNA_EXT1
+#include "audio.h"        // for audio_get_next_mic_sample, audio_open_input
+#include "band.h"         // for band_get_band, BAND
+#include "discovered.h"   // for DISCOVERED, _DISCOVERED::(anonymous), network
+#include "ext.h"          // for ext_mox_update
+#include "iambic.h"       // for keyer_event
+#include "mode.h"         // for modeCWL, modeCWU
+#include "radio.h"        // for isTransmitting, radio, receiver, transmitter
+#include "receiver.h"     // for RECEIVER, add_iq_samples, add_div_iq_samples
+#include "transmitter.h"  // for TRANSMITTER, add_mic_sample, add_ps_iq_samples
+#include "vfo.h"          // for _vfo, vfo, get_tx_mode, get_tx_vfo, VFO_A
 
 #define min(x,y) (x<y?x:y)
 
diff --git a/new_protocol_programmer.c b/new_protocol_programmer.c
index 1b26519..338dcfd 100644
--- a/new_protocol_programmer.c
+++ b/new_protocol_programmer.c
@@ -16,31 +16,17 @@
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <net/if_arp.h>
-#include <net/if.h>
-#include <sys/stat.h>
-#include <ifaddrs.h>
-#include <pthread.h>
-#include <semaphore.h>
-#include <time.h>
-#include <math.h>
-#include <errno.h>
-
-#include <gtk/gtk.h>
-
-#include "discovered.h"
-#include "new_protocol.h"
+#include <errno.h>         // for errno, ETIMEDOUT
+#include <netinet/in.h>    // for sockaddr_in, htons
+#include <pthread.h>       // for pthread_create, pthread_t
+#include <semaphore.h>     // for sem_timedwait
+#include <stdio.h>         // for fprintf, stderr, fseek, NULL, fclose, fopen
+#include <stdlib.h>        // for exit, malloc
+#include <string.h>        // for memcpy, memset
+#include <sys/socket.h>    // for sendto
+#include <time.h>          // for clock_gettime, timespec, CLOCK_REALTIME
+#include "discovered.h"    // for DISCOVERED, _DISCOVERED::(anonymous), network
+#include "new_protocol.h"  // for response, response_sem, data_socket, PROGR...
 
 static long sequence;
 static long block_sequence;
diff --git a/noise_menu.c b/noise_menu.c
index d15f424..0b5e7e7 100644
--- a/noise_menu.c
+++ b/noise_menu.c
@@ -17,25 +17,19 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include <wdsp.h>
-
-#include "new_menu.h"
 #include "noise_menu.h"
-#include "channel.h"
-#include "band.h"
-#include "bandstack.h"
-#include "filter.h"
-#include "mode.h"
-#include "radio.h"
-#include "vfo.h"
-#include "button_text.h"
-#include "ext.h"
+#include <gdk/gdk.h>           // for GdkRGBA, GdkEvent, GdkEventButton
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for gpointer, TRUE, g_idle_add, gboolean
+#include <gtk/gtk.h>           // for gtk_grid_attach, gtk_widget_show, gtk_...
+#include <stdio.h>             // for NULL, sprintf
+#include <wdsp.h>              // for SetEXTANBAdvtime, SetEXTANBHangtime
+#include "ext.h"               // for ext_vfo_update
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "new_menu.h"          // for sub_menu, NO_MENU, active_menu
+#include "radio.h"             // for active_receiver
+#include "receiver.h"          // for RECEIVER
+#include "vfo.h"               // for _mode_settings, _vfo, mode_settings, vfo
 
 static GtkWidget *parent_window=NULL;
 
diff --git a/noise_menu.h b/noise_menu.h
index be535b4..4993bc0 100644
--- a/noise_menu.h
+++ b/noise_menu.h
@@ -16,6 +16,7 @@
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
+#include <gtk/gtk.h>  // for GtkWidget
 
 extern void noise_menu(GtkWidget *parent);
 
diff --git a/oc_menu.c b/oc_menu.c
index aa91f4b..78df601 100644
--- a/oc_menu.c
+++ b/oc_menu.c
@@ -17,21 +17,20 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <semaphore.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "new_menu.h"
 #include "oc_menu.h"
-#include "band.h"
-#include "bandstack.h"
-#include "filter.h"
-#include "radio.h"
-#include "new_protocol.h"
+#include <gdk/gdk.h>           // for GdkRGBA, GdkEvent, GdkEventButton
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for gpointer, g_print, gboolean, FALSE, TRUE
+#include <glib/gtypes.h>       // for GPOINTER_TO_UINT
+#include <gtk/gtk.h>           // for gtk_grid_attach, gtk_widget_show, GtkW...
+#include <stdio.h>             // for NULL, fprintf, sprintf, stderr
+#include <string.h>            // for strlen
+#include "band.h"              // for BAND, band_get_band, BANDS, band10, band6
+#include "discovered.h"        // for NEW_PROTOCOL, DEVICE_HERMES_LITE, DEVI...
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "new_menu.h"          // for sub_menu
+#include "new_protocol.h"      // for schedule_high_priority
+#include "radio.h"             // for OCtune, protocol, OCfull_tune_time
 
 static GtkWidget *parent_window=NULL;
 
diff --git a/oc_menu.h b/oc_menu.h
index 6988a59..c509250 100644
--- a/oc_menu.h
+++ b/oc_menu.h
@@ -16,5 +16,6 @@
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
+#include <gtk/gtk.h>  // for GtkWidget
 
 extern void oc_menu(GtkWidget *parent);
diff --git a/old_discovery.c b/old_discovery.c
index 8c8cfc0..6eeacae 100644
--- a/old_discovery.c
+++ b/old_discovery.c
@@ -17,27 +17,23 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <net/if_arp.h>
-#include <net/if.h>
-#include <ifaddrs.h>
-#include <string.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/select.h>
-
-#include "discovered.h"
-#include "discovery.h"
 #include "old_discovery.h"
-#include "log.h"
+#include <arpa/inet.h>   // for inet_ntoa, inet_aton
+#include <errno.h>       // for errno, EINPROGRESS
+#include <fcntl.h>       // for fcntl, F_SETFL, O_NONBLOCK, F_GETFL
+#include <glib.h>        // for gpointer, g_main_context_iteration, g_thread...
+#include <ifaddrs.h>     // for ifaddrs, freeifaddrs, getifaddrs
+#include <net/if.h>      // for IFF_RUNNING, IFF_UP
+#include <netinet/in.h>  // for sockaddr_in, in_addr, htons, INADDR_BROADCAST
+#include <stdio.h>       // for perror, NULL, size_t
+#include <stdlib.h>      // for exit
+#include <string.h>      // for strcpy, memcpy, memset, strerror
+#include <sys/select.h>  // for timeval, select, FD_SET, FD_ZERO, fd_set
+#include <sys/socket.h>  // for setsockopt, socket, AF_INET, SOL_SOCKET, bind
+#include <unistd.h>      // for close
+#include "discovered.h"  // for DISCOVERED, discovered, devices, _DISCOVERED...
+#include "discovery.h"   // for ipaddr_tcp
+#include "log.h"         // for log_trace, log_error, log_debug
 
 static char interface_name[64];
 static struct sockaddr_in interface_addr={0};
diff --git a/old_protocol.c b/old_protocol.c
index f8f29f7..2b7e4cf 100644
--- a/old_protocol.c
+++ b/old_protocol.c
@@ -17,44 +17,31 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/time.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <net/if_arp.h>
-#include <net/if.h>
-#include <ifaddrs.h>
-#include <semaphore.h>
-#include <string.h>
-#include <errno.h>
-#include <math.h>
-#include <stdbool.h>
-
-#include <wdsp.h>
-
-#include "audio.h"
-#include "band.h"
-#include "channel.h"
-#include "discovered.h"
-#include "mode.h"
-#include "filter.h"
 #include "old_protocol.h"
-#include "radio.h"
-#include "receiver.h"
-#include "transmitter.h"
-#include "signal.h"
-#include "toolbar.h"
-#include "vfo.h"
-#include "ext.h"
-#include "iambic.h"
-#include "error_handler.h"
-#include "log.h"
+#include <arpa/inet.h>    // for inet_ntoa
+#include <errno.h>        // for errno, EAGAIN
+#include <glib.h>         // for gpointer, g_idle_add, g_thread_new, GThread
+#include <math.h>         // for sqrt
+#include <netinet/in.h>   // for sockaddr_in, htons, ntohs, IPPROTO_UDP
+#include <stdint.h>       // for uint32_t
+#include <stdio.h>        // for perror, NULL, size_t
+#include <stdlib.h>       // for exit
+#include <string.h>       // for memcpy, strerror
+#include <sys/socket.h>   // for setsockopt, SOL_SOCKET, recvfrom, sendto
+#include <sys/time.h>     // for timeval, gettimeofday
+#include <unistd.h>       // for usleep, close
+#include "adc.h"          // for ADC
+#include "audio.h"        // for audio_get_next_mic_sample, audio_open_input
+#include "band.h"         // for band_get_band, BAND, band_get_current, band...
+#include "discovered.h"   // for DISCOVERED, _DISCOVERED::(anonymous), network
+#include "ext.h"          // for ext_mox_update
+#include "iambic.h"       // for keyer_event
+#include "log.h"          // for log_error, log_trace, log_info, log_debug
+#include "mode.h"         // for modeCWL, modeCWU
+#include "radio.h"        // for isTransmitting, transmitter, receiver, device
+#include "receiver.h"     // for RECEIVER, add_iq_samples, add_div_iq_samples
+#include "transmitter.h"  // for TRANSMITTER, add_mic_sample, add_ps_iq_samples
+#include "vfo.h"          // for _vfo, vfo, get_tx_vfo, get_tx_mode, VFO_A
 
 #define min(x,y) (x<y?x:y)
 
@@ -404,7 +391,7 @@ static void open_udp_socket() {
     }
 
     // bind to the interface
-    log_trace("binding UDP socket to %s:%d\n",inet_ntoa(radio->info.network.interface_address.sin_addr),ntohs(radio->info.network.interface_address.sin_port));
+    log_trace("binding UDP socket to %s:%d",inet_ntoa(radio->info.network.interface_address.sin_addr),ntohs(radio->info.network.interface_address.sin_port));
     if(bind(tmp,(struct sockaddr*)&radio->info.network.interface_address,radio->info.network.interface_length)<0) {
 	log_error("old_protocol: bind socket failed for data_socket: %s", strerror(errno));
 	exit(-1);
diff --git a/old_protocol.h b/old_protocol.h
index 49f6e7c..e09b071 100644
--- a/old_protocol.h
+++ b/old_protocol.h
@@ -20,6 +20,8 @@
 #ifndef _OLD_PROTOCOL_H
 #define _OLD_PROTOCOL_H
 
+#include "receiver.h"  // for RECEIVER
+
 extern void old_protocol_stop();
 extern void old_protocol_run();
 
diff --git a/pa_menu.c b/pa_menu.c
index fc9c8d2..d8ac776 100644
--- a/pa_menu.c
+++ b/pa_menu.c
@@ -17,17 +17,20 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <semaphore.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "new_menu.h"
 #include "pa_menu.h"
-#include "band.h"
-#include "radio.h"
-#include "vfo.h"
+#include <gdk/gdk.h>           // for GdkRGBA, GdkEvent, GdkEventButton
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for FALSE, TRUE, gpointer, gboolean, g_print
+#include <glib/gtypes.h>       // for GINT_TO_POINTER, GPOINTER_TO_INT
+#include <gtk/gtk.h>           // for gtk_grid_attach, GtkWidget, gtk_combo_...
+#include <stdio.h>             // for NULL, sprintf
+#include <string.h>            // for strlen
+#include "band.h"              // for BAND, band_get_band, BANDS, band10, band6
+#include "discovered.h"        // for DEVICE_HERMES_LITE, DEVICE_HERMES_LITE2
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "new_menu.h"          // for sub_menu
+#include "radio.h"             // for pa_trim, pa_power, calcDriveLevel, tx_...
+#include "vfo.h"               // for get_tx_vfo, _vfo, vfo
 
 static GtkWidget *parent_window=NULL;
 
diff --git a/pa_menu.h b/pa_menu.h
index 03f440b..63e47c7 100644
--- a/pa_menu.h
+++ b/pa_menu.h
@@ -18,7 +18,5 @@
 */
 
 #include <gtk/gtk.h>
-#include <stdio.h>
-#include <string.h>
 
 extern void pa_menu(GtkWidget *parent);
diff --git a/property.c b/property.c
index e520961..1679d87 100644
--- a/property.c
+++ b/property.c
@@ -17,13 +17,11 @@
 *
 */
 
-#include <gtk/gtk.h>
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
 #include "property.h"
-#include "log.h"
+#include <stdio.h>   // for NULL, fclose, fopen, sprintf, fgets, fwrite, FILE
+#include <stdlib.h>  // for malloc, free, atof
+#include <string.h>  // for strlen, strcpy, strcmp, strtok
+#include "log.h"     // for log_error
 
 PROPERTY* properties=NULL;
 
diff --git a/property.h b/property.h
index ae41979..a0d9e12 100644
--- a/property.h
+++ b/property.h
@@ -22,6 +22,7 @@
 
 #define PROPERTY_VERSION 3.0
 
+struct _PROPERTY;
 typedef struct _PROPERTY PROPERTY;
 
 /* --------------------------------------------------------------------------*/
diff --git a/protocols.c b/protocols.c
index 0b23f8b..3be1b33 100644
--- a/protocols.c
+++ b/protocols.c
@@ -17,19 +17,14 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <gdk/gdk.h>
-#include <math.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <semaphore.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
 #include "protocols.h"
-#include "property.h"
-
+#include <gdk/gdk.h>           // for GdkEventButton
+#include <glib-object.h>       // for g_signal_connect
+#include <gtk/gtk.h>           // for gtk_grid_attach, GtkWidget, gtk_check_...
+#include <stdio.h>             // for sprintf
+#include <stdlib.h>            // for atoi, NULL
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "property.h"          // for getProperty, setProperty, clearProperties
 
 static GtkWidget *dialog;
 
diff --git a/protocols.h b/protocols.h
index 3d3571e..a19bc1d 100644
--- a/protocols.h
+++ b/protocols.h
@@ -17,6 +17,9 @@
 *
 */
 
+#include <glib.h>     // for gboolean
+#include <gtk/gtk.h>  // for GtkWidget
+
 extern gboolean enable_protocol_1;
 extern gboolean enable_protocol_2;
 extern gboolean autostart;
diff --git a/radio.c b/radio.c
index 5eceae4..1cd5cef 100644
--- a/radio.c
+++ b/radio.c
@@ -17,71 +17,49 @@
  *
  */
 
-#include <arpa/inet.h>
-#include <gtk/gtk.h>
-#include <math.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <semaphore.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <stdbool.h>
-
-#include <wdsp.h>
-
-#include "adc.h"
-#include "audio.h"
-#include "dac.h"
-#include "discovered.h"
-// #include "discovery.h"
-#include "actions.h"
-#include "agc.h"
-#include "band.h"
-#include "channel.h"
-#include "ext.h"
-#include "filter.h"
-#include "gpio.h"
-#include "main.h"
-#include "meter.h"
-#include "mode.h"
-#include "new_menu.h"
-#include "new_protocol.h"
-#include "old_protocol.h"
-#include "property.h"
 #include "radio.h"
-#include "receiver.h"
-#include "rigctl.h"
-#include "rx_panadapter.h"
-#include "screen.h"
-#include "sliders.h"
-#include "store.h"
-#include "toolbar.h"
-#include "transmitter.h"
-#include "tx_panadapter.h"
-#include "vfo.h"
-#include "vox.h"
-#include "waterfall.h"
-#include "zoompan.h"
-#include "log.h"
-
-#ifdef LOCALCW
-#include "iambic.h"
-#endif
-#ifdef MIDI
-#include "alsa_midi.h"
-#include "midi_menu.h"
-// rather than including MIDI.h with all its internal stuff
-// (e.g. enum components) we just declare the single bit thereof
-// we need here to make a strict compiler happy.
-// extern void MIDIstartup();
-#endif
-#ifdef CLIENT_SERVER
-#include "client_server.h"
-#endif
+#include <arpa/inet.h>         // for inet_ntoa
+#include <gdk/gdk.h>           // for gdk_cursor_new, gdk_window_set_cursor
+#include <glib-object.h>       // for g_object_ref, g_signal_connect
+#include <gtk/gtk.h>           // for gtk_fixed_put, gtk_container_remove
+#include <math.h>              // for fmin, pow, exp, log10, sqrt
+#include <netinet/in.h>        // for sockaddr_in
+#include <stdio.h>             // for sprintf, NULL
+#include <stdlib.h>            // for atoi, atof, atoll
+#include <string.h>            // for strcpy
+#include <sys/time.h>          // for gettimeofday, timeval
+#include <unistd.h>            // for usleep
+#include <wdsp.h>              // for SetChannelState, CloseChannel, SetTXAP...
+#include "adc.h"               // for ADC, ANTENNA_1, AUTOMATIC, HPF_13, HPF...
+#include "band.h"              // for bandstack60, get_band_from_frequency
+#include "bandstack.h"         // for BANDSTACK
+#include "channel.h"           // for CHANNEL_TX
+#include "dac.h"               // for DAC
+#include "discovered.h"        // for DISCOVERED, NEW_PROTOCOL, _DISCOVERED:...
+#include "ext.h"               // for ext_vfo_update
+#include "filter.h"            // for filterRestoreState, filterSaveState
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "gpio.h"              // for gpio_init, gpio_restore_actions, gpio_...
+#include "iambic.h"            // for keyer_update
+#include "log.h"               // for log_trace, log_error
+#include "main.h"              // for display_width, top_window, display_height
+#include "meter.h"             // for meter_init
+#include "mode.h"              // for modeUSB, modeCWL, modeCWU, modeLSB
+#include "new_menu.h"          // for new_menu
+#include "new_protocol.h"      // for schedule_high_priority, schedule_recei...
+#include "old_protocol.h"      // for old_protocol_run, old_protocol_stop
+#include "pango/pango-font.h"  // for pango_font_description_from_string
+#include "property.h"          // for setProperty, getProperty, clearProperties
+#include "receiver.h"          // for RECEIVER, set_displaying, set_offset
+#include "rigctl.h"            // for close_rigctl_ports, launch_rigctl, lau...
+#include "screen.h"            // for SLIDERS_HEIGHT, ZOOMPAN_HEIGHT, TOOLBA...
+#include "sliders.h"           // for sliders_init, att_type_changed
+#include "store.h"             // for memRestoreState, memSaveState
+#include "toolbar.h"           // for toolbar_init
+#include "transmitter.h"       // for TRANSMITTER, tx_set_mode, create_trans...
+#include "vfo.h"               // for _vfo, vfo, get_tx_mode, get_tx_vfo
+#include "vox.h"               // for vox_cancel
+#include "zoompan.h"           // for zoompan_init
 
 #define min(x, y) (x < y ? x : y)
 #define max(x, y) (x < y ? y : x)
diff --git a/radio.h b/radio.h
index 2cc368a..8d7cb7a 100644
--- a/radio.h
+++ b/radio.h
@@ -20,11 +20,13 @@
 #ifndef _RADIO_H
 #define _RADIO_H
 
-#include "adc.h"
-#include "dac.h"
-#include "discovered.h"
-#include "receiver.h"
-#include "transmitter.h"
+#include <glib.h>         // for gboolean, gint, GMutex
+#include <gtk/gtk.h>      // for GtkWidget
+#include "adc.h"          // for ADC
+#include "dac.h"          // for DAC
+#include "discovered.h"   // for DISCOVERED
+#include "receiver.h"     // for RECEIVER
+#include "transmitter.h"  // for TRANSMITTER
 
 #define NEW_MIC_IN 0x00
 #define NEW_LINE_IN 0x01
diff --git a/radio_menu.c b/radio_menu.c
index 0a70f4c..c47a1b2 100644
--- a/radio_menu.c
+++ b/radio_menu.c
@@ -17,35 +17,24 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <semaphore.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "main.h"
-#include "discovered.h"
-#include "new_menu.h"
 #include "radio_menu.h"
-#include "adc.h"
-#include "band.h"
-#include "filter.h"
-#include "radio.h"
-#include "receiver.h"
-#include "sliders.h"
-#include "new_protocol.h"
-#include "old_protocol.h"
-#include "actions.h"
-#ifdef GPIO
-#include "gpio.h"
-#endif
-#include "vfo.h"
-#include "ext.h"
-#ifdef CLIENT_SERVER
-#include "client_server.h"
-#endif
+#include <gdk/gdk.h>           // for GdkRGBA, GdkEvent, GdkEventButton
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for gpointer, g_idle_add, FALSE, gboolean
+#include <glib/gtypes.h>       // for GPOINTER_TO_INT
+#include <gtk/gtk.h>           // for gtk_grid_attach, gtk_toggle_button_set...
+#include <stdio.h>             // for NULL
+#include "band.h"              // for band_get_band, BAND, band_get_current_...
+#include "discovered.h"        // for NEW_PROTOCOL, ORIGINAL_PROTOCOL, DISCO...
+#include "ext.h"               // for ext_vfo_update, ext_split_toggle
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "main.h"              // for display_width, display_height
+#include "new_menu.h"          // for sub_menu
+#include "new_protocol.h"      // for filter_board_changed, schedule_high_pr...
+#include "radio.h"             // for filter_board, protocol, active_receiver
+#include "receiver.h"          // for RECEIVER
+#include "sliders.h"           // for att_type_changed
+#include "transmitter.h"       // for reconfigure_transmitter, TRANSMITTER
 
 static GtkWidget *parent_window=NULL;
 static GtkWidget *dialog=NULL;
diff --git a/radio_menu.h b/radio_menu.h
index b2d495d..a101522 100644
--- a/radio_menu.h
+++ b/radio_menu.h
@@ -17,6 +17,8 @@
 *
 */
 
+#include <gtk/gtk.h>  // for GtkWidget
+
 extern void radio_menu(GtkWidget *parent);
 extern void setDuplex(void);
 extern void load_filters(void);
diff --git a/receiver.c b/receiver.c
index c5b6b65..f34dc1e 100644
--- a/receiver.c
+++ b/receiver.c
@@ -17,41 +17,34 @@
  *
  */
 
-#include <gtk/gtk.h>
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdbool.h>
-
-#include <wdsp.h>
-
-#include "agc.h"
-#include "audio.h"
-#include "band.h"
-#include "bandstack.h"
-#include "channel.h"
-#include "discovered.h"
-#include "ext.h"
-#include "filter.h"
-#include "main.h"
-#include "meter.h"
-#include "mode.h"
-#include "new_menu.h"
-#include "new_protocol.h"
-#include "old_protocol.h"
-#include "property.h"
-#include "radio.h"
 #include "receiver.h"
-#include "rx_panadapter.h"
-#include "sliders.h"
-#include "transmitter.h"
-#include "vfo.h"
-#include "waterfall.h"
-#include "zoompan.h"
-#ifdef CLIENT_SERVER
-#include "client_server.h"
-#endif
-#include "log.h"
+#include <glib-object.h>    // for g_object_weak_ref, G_OBJECT, GObject
+#include <gtk/gtk.h>        // for gtk_fixed_put, gtk_widget_set_size_request
+#include <math.h>           // for ceil, fmax
+#include <stdio.h>          // for sprintf, NULL
+#include <stdlib.h>         // for atoi, atof, malloc
+#include <string.h>         // for strcpy, strlen
+#include <wdsp.h>           // for SetRXAAGCAttack, SetRXAAGCDecay, SetRXAAG...
+#include "agc.h"            // for AGC_MEDIUM, AGC_FAST, AGC_LONG, AGC_OFF
+#include "audio.h"          // for audio_open_output, audio_write
+#include "band.h"           // for BAND, band_get_band
+#include "discovered.h"     // for NEW_PROTOCOL, ORIGINAL_PROTOCOL, DEVICE_H...
+#include "ext.h"            // for ext_start_rx, ext_vfo_update
+#include "filter.h"         // for FILTER, filters
+#include "log.h"            // for log_trace, log_debug, log_error
+#include "meter.h"          // for meter_update, SMETER
+#include "mode.h"           // for modeCWL, modeCWU, modeFMN
+#include "new_menu.h"       // for menu_active_receiver_changed
+#include "new_protocol.h"   // for new_protocol_audio_samples, schedule_high...
+#include "old_protocol.h"   // for old_protocol_audio_samples
+#include "property.h"       // for getProperty, setProperty
+#include "radio.h"          // for active_receiver, isTransmitting, cw_keyer...
+#include "rx_panadapter.h"  // for rx_panadapter_init, rx_panadapter_update
+#include "sliders.h"        // for sliders_active_receiver_changed
+#include "transmitter.h"    // for tx_set_filter, tx_set_mode, TRANSMITTER
+#include "vfo.h"            // for _vfo, vfo, vfo_move, vfo_step, get_tx_mode
+#include "waterfall.h"      // for waterfall_init, waterfall_update
+#include "zoompan.h"        // for set_pan, zoompan_active_receiver_changed
 
 #define min(x, y) (x < y ? x : y)
 #define max(x, y) (x < y ? y : x)
diff --git a/receiver.h b/receiver.h
index 59b53de..bcc56d0 100644
--- a/receiver.h
+++ b/receiver.h
@@ -19,13 +19,13 @@
 #ifndef _RECEIVER_H
 #define _RECEIVER_H
 
-#include <gtk/gtk.h>
-#ifdef PORTAUDIO
-#include "portaudio.h"
-#else
-#include <pulse/pulseaudio.h>
-#include <pulse/simple.h>
-#endif
+#include <gdk-pixbuf/gdk-pixbuf.h>  // for GdkPixbuf
+#include <gdk/gdk.h>                // for GdkEventButton, GdkEventMotion
+#include <glib.h>                   // for gint, gdouble, gboolean, gpointer
+#include <glib/gtypes.h>            // for gint64, guint32
+#include <gtk/gtk.h>                // for GtkWidget
+#include <pulse/simple.h>           // for pa_simple
+#include "cairo.h"                  // for cairo_surface_t
 
 enum _audio_t {
     STEREO=0,
diff --git a/rigctl.c b/rigctl.c
index e36303e..a1fd6f1 100644
--- a/rigctl.c
+++ b/rigctl.c
@@ -20,49 +20,42 @@
  * greatly with hamlib integration!
  */
 
-#include <stdbool.h>
-
-#include <errno.h>
-#include <fcntl.h>
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
-// #include <semaphore.h>
-#include "agc.h"
-#include "band.h"
-#include "band_menu.h"
-#include "bandstack.h"
-#include "channel.h"
-#include "ext.h"
-#include "filter.h"
-#include "filter_menu.h"
-#include "mode.h"
-#include "new_menu.h"
-#include "new_protocol.h"
-#include "noise_menu.h"
-#include "old_protocol.h"
-#include "radio.h"
-#include "receiver.h"
 #include "rigctl.h"
-#include "rigctl_menu.h"
-#include "rx_menu.h"
-#include "sliders.h"
-#include "store.h"
-#include "toolbar.h"
-#include "transmitter.h"
-#include "vfo.h"
-#include "zoompan.h"
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <wdsp.h>
-#ifdef LOCALCW
-#include "iambic.h" // declare keyer_update()
-#endif
-#include <math.h>
-#include "log.h"
+#include <termios.h>
+#include <errno.h>                 // for errno
+#include <fcntl.h>                 // for fcntl, O_NONBLOCK, open, F_GETFL
+#include <glib/gtypes.h>           // for GPOINTER_TO_INT
+#include <math.h>                  // for fmin, fmax, round
+#include <netinet/in.h>            // for sockaddr_in, INADDR_ANY, htons
+#include <stdbool.h>               // for false, true, bool
+#include <stdio.h>                 // for sprintf, NULL, perror, FILE, ssize_t
+#include <stdlib.h>                // for atoi, strtol, atoll, abs, atof
+#include <string.h>                // for strcpy, strerror, strncpy, memset
+#include <sys/socket.h>            // for setsockopt, linger, SOL_SOCKET
+#include <termios.h>               // for tcgetattr, tcsetattr, cc_t, cfseti...
+#include <unistd.h>                // for usleep, close, _exit, read, write
+#include <wdsp.h>                  // for SetRXAANFRun
+#include "adc.h"                   // for ADC
+#include "band.h"                  // for band20, band10, band12, band136
+#include "discovered.h"            // for ORIGINAL_PROTOCOL
+#include "ext.h"                   // for local_set_frequency, band_minus
+#include "filter.h"                // for FILTER, filterVar1, filters, FILTERS
+#include "iambic.h"                // for keyer_update
+#include "log.h"                   // for log_error, log_debug, log_trace
+#include "mode.h"                  // for modeLSB, modeAM, modeCWL, modeCWU
+#include "new_menu.h"              // for start_bandstack
+#include "new_protocol.h"          // for new_protocol_stop
+#include "noise_menu.h"            // for update_noise
+#include "old_protocol.h"          // for old_protocol_stop
+#include "radio.h"                 // for receiver, active_receiver, transmi...
+#include "receiver.h"              // for RECEIVER, set_agc
+#include "rigctl_menu.h"           // for rigctl_debug, ser_port, disable_se...
+#include "rx_menu.h"               // for toggle_audio_output_device
+#include "sliders.h"               // for update_af_gain, set_agc_gain, set_...
+#include "toolbar.h"               // for mox_update, tune_update
+#include "transmitter.h"           // for TRANSMITTER, tx_set_mode, cw_not_r...
+#include "vfo.h"                   // for _vfo, vfo_update, vfo, VFO_A, vfo_...
+#include "zoompan.h"               // for set_zoom
 
 #define NEW_PARSER
 
diff --git a/rigctl.h b/rigctl.h
index f0b4d31..f45ff8d 100644
--- a/rigctl.h
+++ b/rigctl.h
@@ -1,7 +1,9 @@
 #ifndef RIGCTL_H
 #define RIGCTL_H
 
-#include <stdbool.h>
+#include <glib.h>     // for gpointer
+#include <stdbool.h>  // for bool
+#include <stdint.h>   // for uint32_t
 
 void launch_rigctl ();
 int launch_serial ();
diff --git a/rigctl_menu.c b/rigctl_menu.c
index 469e679..4d92c23 100644
--- a/rigctl_menu.c
+++ b/rigctl_menu.c
@@ -17,21 +17,19 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <semaphore.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include "new_menu.h"
 #include "rigctl_menu.h"
-#include "rigctl.h"
-#include "band.h"
-#include "radio.h"
-#include "vfo.h"
-#include "log.h"
+#include <gdk/gdk.h>           // for GdkRGBA, GdkEvent, GdkEventButton
+#include <glib-object.h>       // for g_signal_connect
+#include <glib/gtypes.h>       // for GPOINTER_TO_INT
+#include <gtk/gtk.h>           // for gtk_grid_attach, gtk_widget_show, GtkW...
+#include <stdio.h>             // for NULL
+#include <string.h>            // for strcpy
+#include <termios.h>           // for B9600, B19200, B38400, B4800
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "log.h"               // for log_trace, log_debug
+#include "new_menu.h"          // for sub_menu
+#include "radio.h"             // for disable_rigctl
+#include "rigctl.h"            // for launch_rigctl, launch_serial, rigctl_e...
 
 gboolean  serial_enable = TRUE; // edit (enable serial at startup)
 char ser_port[64]="/dev/ttyACM0";
diff --git a/rigctl_menu.h b/rigctl_menu.h
index 64a9d27..f409940 100644
--- a/rigctl_menu.h
+++ b/rigctl_menu.h
@@ -17,9 +17,8 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <stdio.h>
-#include <string.h>
+#include <glib.h>     // for gboolean
+#include <gtk/gtk.h>  // for GtkWidget
 
 extern void rigctl_menu(GtkWidget *parent);
 extern char ser_port[];
diff --git a/rx_menu.c b/rx_menu.c
index fb15bf1..a24aace 100644
--- a/rx_menu.c
+++ b/rx_menu.c
@@ -17,24 +17,24 @@
  *
  */
 
-#include <gtk/gtk.h>
-#include <semaphore.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "audio.h"
-#include "band.h"
-#include "discovered.h"
-#include "filter.h"
-#include "new_menu.h"
-#include "new_protocol.h"
-#include "radio.h"
-#include "receiver.h"
 #include "rx_menu.h"
-#include "sliders.h"
-#include "log.h"
+#include <gdk/gdk.h>           // for GdkRGBA, GdkEvent, GdkEventButton
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for gpointer, g_malloc, g_free, g_malloc_n
+#include <glib/gtypes.h>       // for GINT_TO_POINTER, GPOINTER_TO_INT
+#include <gtk/gtk.h>           // for gtk_grid_attach, gtk_toggle_button_set...
+#include <stdint.h>            // for intptr_t
+#include <stdio.h>             // for NULL, sprintf, size_t
+#include <string.h>            // for strcpy, strlen, strcmp
+#include "audio.h"             // for AUDIO_DEVICE, audio_close_output, audi...
+#include "discovered.h"        // for NEW_PROTOCOL, ORIGINAL_PROTOCOL, DEVIC...
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "log.h"               // for log_trace, log_error
+#include "new_menu.h"          // for sub_menu
+#include "new_protocol.h"      // for schedule_high_priority
+#include "radio.h"             // for active_receiver, protocol, device, set...
+#include "receiver.h"          // for RECEIVER, receiver_change_adc, receive...
+#include "sliders.h"           // for update_att_preamp
 
 static GtkWidget *parent_window = NULL;
 static GtkWidget *dialog = NULL;
diff --git a/rx_menu.h b/rx_menu.h
index 1342234..ac58e70 100644
--- a/rx_menu.h
+++ b/rx_menu.h
@@ -17,5 +17,7 @@
  *
  */
 
+#include <gtk/gtk.h>  // for GtkWidget
+
 extern void rx_menu(GtkWidget *parent);
 extern void toggle_audio_output_device(void);
diff --git a/rx_panadapter.c b/rx_panadapter.c
index 78b3988..72a7ea3 100644
--- a/rx_panadapter.c
+++ b/rx_panadapter.c
@@ -17,35 +17,24 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <gdk/gdk.h>
-#include <math.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <semaphore.h>
-#include <arpa/inet.h>
-#include <stdbool.h>
-
-#include <wdsp.h>
-
-#include "agc.h"
-#include "band.h"
-#include "channel.h"
-#include "discovered.h"
-#include "radio.h"
-#include "receiver.h"
-#include "transmitter.h"
 #include "rx_panadapter.h"
-#include "vfo.h"
-#include "mode.h"
-#include "actions.h"
-#ifdef GPIO
-#include "gpio.h"
-#endif
-#ifdef CLIENT_SERVER
-#include "client_server.h"
-#endif
+#include <gdk/gdk.h>           // for gdk_window_create_similar_surface, Gdk...
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for gboolean, gpointer, gfloat, FALSE, TRUE
+#include <gtk/gtk.h>           // for GtkWidget, gtk_widget_get_allocated_he...
+#include <math.h>              // for floor
+#include <stdio.h>             // for sprintf
+#include <stdlib.h>            // for abs, NULL
+#include "adc.h"               // for ADC
+#include "agc.h"               // for AGC_FAST, AGC_MEDIUM, AGC_OFF
+#include "band.h"              // for BAND, CHANNEL, band_channels_60m, band...
+#include "cairo.h"             // for cairo_move_to, cairo_set_source_rgb
+#include "discovered.h"        // for DEVICE_HERMES_LITE2, ORIGINAL_PROTOCOL
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "mode.h"              // for modeCWL, modeCWU
+#include "radio.h"             // for adc, filter_board, ALEX, cw_keyer_side...
+#include "receiver.h"          // for RECEIVER, receiver_button_press_event
+#include "vfo.h"               // for _vfo, vfo
 
 #define LINE_WIDTH 0.5
 
diff --git a/rx_panadapter.h b/rx_panadapter.h
index 3481d8a..45846c8 100644
--- a/rx_panadapter.h
+++ b/rx_panadapter.h
@@ -20,6 +20,8 @@
 #ifndef _PANADAPTER_H
 #define _PANADAPTER_H
 
+#include "receiver.h"  // for RECEIVER
+
 void rx_panadapter_update(RECEIVER* rx);
 
 void rx_panadapter_init(RECEIVER *rx,int width,int height);
diff --git a/sliders.c b/sliders.c
index 9b71c40..700e51d 100644
--- a/sliders.c
+++ b/sliders.c
@@ -29,36 +29,23 @@
 //#define COMPRESSION_SLIDER_INSTEAD_OF_SQUELCH 1
 //
 
-#include <gtk/gtk.h>
-#include <semaphore.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <stdbool.h>
-
-#include "receiver.h"
 #include "sliders.h"
-#include "mode.h"
-#include "filter.h"
-#include "bandstack.h"
-#include "band.h"
-#include "discovered.h"
-#include "new_protocol.h"
-#include "vfo.h"
-#include "alex.h"
-#include "agc.h"
-#include "channel.h"
-#include "wdsp.h"
-#include "radio.h"
-#include "transmitter.h"
-#include "property.h"
-#include "main.h"
-#include "ext.h"
-#ifdef CLIENT_SERVER
-#include "client_server.h"
-#endif
-#include "actions.h"
-#include "log.h"
+#include <glib-object.h>       // for g_signal_connect, G_OBJECT
+#include <gtk/gtk.h>           // for gtk_range_set_value, gtk_widget_show
+#include <math.h>              // for pow
+#include <stdio.h>             // for NULL, sprintf
+#include <stdlib.h>            // for atoi, free
+#include "actions.h"           // for AF_GAIN, AGC_GAIN, ATTENUATION, COMPRE...
+#include "adc.h"               // for ADC
+#include "ext.h"               // for ext_vfo_update
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "log.h"               // for log_trace
+#include "main.h"              // for top_window
+#include "pango/pango-font.h"  // for pango_font_description_from_string
+#include "radio.h"             // for active_receiver, adc, receiver, displa...
+#include "receiver.h"          // for RECEIVER
+#include "transmitter.h"       // for TRANSMITTER
+#include "wdsp.h"              // for GetRXAAGCHangLevel, GetRXAAGCThresh
 
 static int width;
 static int height;
diff --git a/sliders.h b/sliders.h
index c532bdb..ca03299 100644
--- a/sliders.h
+++ b/sliders.h
@@ -18,9 +18,9 @@
 #ifndef _SLIDERS_H
 #define _SLIDERS_H
 
-// include these since we are using RECEIVER and TRANSMITTER
-#include "receiver.h"
-#include "transmitter.h"
+#include <glib.h>         // for gint, gpointer
+#include <gtk/gtk.h>      // for GtkWidget
+#include "transmitter.h"  // for TRANSMITTER
 
 enum {
   NO_FUNCTION=0,
diff --git a/step_menu.c b/step_menu.c
index 711bc21..3923e42 100644
--- a/step_menu.c
+++ b/step_menu.c
@@ -17,17 +17,18 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "new_menu.h"
-#include "radio.h"
-#include "vfo.h"
-#include "ext.h"
+#include <gdk/gdk.h>           // for GdkRGBA, GdkEvent, GdkEventButton
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for gpointer, TRUE, g_idle_add, gboolean
+#include <glib/gtypes.h>       // for GPOINTER_TO_INT
+#include <gtk/gtk.h>           // for GtkWidget, gtk_grid_attach, GTK_GRID
+#include <stdio.h>             // for NULL
+#include "ext.h"               // for ext_vfo_update
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "new_menu.h"          // for sub_menu
+#include "pango/pango-font.h"  // for pango_font_description_from_string
+#include "radio.h"             // for step
+#include "vfo.h"               // for step_labels, steps, STEPS
 
 static GtkWidget *parent_window=NULL;
 
diff --git a/step_menu.h b/step_menu.h
index 45fff22..9720049 100644
--- a/step_menu.h
+++ b/step_menu.h
@@ -16,5 +16,6 @@
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
+#include <gtk/gtk.h>
 
 extern void step_menu(GtkWidget *parent);
diff --git a/store.c b/store.c
index 49f653b..f4b6d56 100644
--- a/store.c
+++ b/store.c
@@ -18,20 +18,15 @@
 *
 */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "bandstack.h"
-#include "band.h"
-#include "filter.h"
-#include "mode.h"
-#include "alex.h"
-#include "property.h"
 #include "store.h"
-#include "store_menu.h"
-#include "log.h"
+#include <stdio.h>       // for sprintf
+#include <stdlib.h>      // for atoi, atoll
+#include <string.h>      // for strcpy, strlen
+#include "filter.h"      // for filterF0
+#include "log.h"         // for log_trace
+#include "mode.h"        // for modeCWU
+#include "property.h"    // for getProperty, setProperty
+#include "store_menu.h"  // for NUM_OF_MEMORYS
 
 /*
 struct MEM {
diff --git a/store_menu.c b/store_menu.c
index bc75ad6..88f6ede 100644
--- a/store_menu.c
+++ b/store_menu.c
@@ -18,27 +18,23 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "new_menu.h"
 #include "store_menu.h"
-#include "band.h"
-#include "bandstack.h"
-#include "filter.h"
-#include "mode.h"
-#include "radio.h"
-#include "rigctl.h"
-#include "band.h"
-#include "vfo.h"
-#include "button_text.h"
-#include "store.h"
-#include "ext.h"
-#include "log.h"
+#include <gdk/gdk.h>           // for GdkRGBA, GdkEvent, GdkEventButton
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for gpointer, gboolean, FALSE, TRUE, g_idl...
+#include <glib/gtypes.h>       // for GPOINTER_TO_INT
+#include <gtk/gtk.h>           // for GtkWidget, gtk_button_new_with_label
+#include <stdio.h>             // for sprintf, NULL
+#include <string.h>            // for strcpy
+#include "band.h"              // for get_band_from_frequency
+#include "ext.h"               // for ext_vfo_update
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "log.h"               // for log_debug, log_trace
+#include "new_menu.h"          // for sub_menu
+#include "radio.h"             // for active_receiver
+#include "receiver.h"          // for RECEIVER
+#include "store.h"             // for MEM, mem, memSaveState
+#include "vfo.h"               // for _vfo, vfo, vfo_filter_changed, vfo_mod...
 
 static GtkWidget *parent_window=NULL;
 
diff --git a/store_menu.h b/store_menu.h
index 4f2d1d8..93d4bd7 100644
--- a/store_menu.h
+++ b/store_menu.h
@@ -16,5 +16,9 @@
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
+
 #define NUM_OF_MEMORYS 5
+
+#include <gtk/gtk.h>  // for GtkWidget
+
 extern void store_menu(GtkWidget *parent);
diff --git a/switch_menu.c b/switch_menu.c
index 7b1e1ff..1d97208 100644
--- a/switch_menu.c
+++ b/switch_menu.c
@@ -17,27 +17,20 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <glib/gprintf.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "main.h"
-#include "new_menu.h"
-#include "agc_menu.h"
-#include "agc.h"
-#include "band.h"
-#include "channel.h"
-#include "radio.h"
-#include "receiver.h"
-#include "vfo.h"
-#include "button_text.h"
-#include "toolbar.h"
-#include "actions.h"
-#include "action_dialog.h"
-#include "gpio.h"
-#include "i2c.h"
+#include <gdk/gdk.h>           // for GdkEvent, GdkEventButton
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for gint, gpointer, TRUE, g_print, gboolean
+#include <glib/gprintf.h>      // for g_sprintf
+#include <glib/gtypes.h>       // for GINT_TO_POINTER, GPOINTER_TO_INT
+#include <gtk/gtk.h>           // for gtk_button_new_with_label, gtk_grid_at...
+#include <stdio.h>             // for NULL
+#include "action_dialog.h"     // for action_dialog
+#include "actions.h"           // for ACTION_TABLE, ActionTable, CONTROLLER_...
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "gpio.h"              // for SWITCH, switches_controller1, MAX_FUNC...
+#include "main.h"              // for controller, CONTROLLER1, NO_CONTROLLER
+#include "new_menu.h"          // for sub_menu, NO_MENU, active_menu
+#include "toolbar.h"           // for update_toolbar_labels
 
 static GtkWidget *parent_window=NULL;
 
diff --git a/toolbar.c b/toolbar.c
index 9c01366..201127b 100644
--- a/toolbar.c
+++ b/toolbar.c
@@ -17,40 +17,23 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <semaphore.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "actions.h"
-#include "gpio.h"
 #include "toolbar.h"
-#include "mode.h"
-#include "filter.h"
-#include "bandstack.h"
-#include "band.h"
-#include "discovered.h"
-#include "new_protocol.h"
-#include "old_protocol.h"
-#include "vfo.h"
-#include "alex.h"
-#include "agc.h"
-#include "channel.h"
-#include "wdsp.h"
-#include "radio.h"
-#include "receiver.h"
-#include "transmitter.h"
-#include "property.h"
-#include "new_menu.h"
-#include "button_text.h"
-#include "ext.h"	
-#ifdef CLIENT_SERVER
-#include "client_server.h"
-#endif
-#include "log.h"
+#include <gdk/gdk.h>           // for GdkRGBA
+#include <glib-object.h>       // for G_OBJECT, g_signal_connect
+#include <glib/gtypes.h>       // for GINT_TO_POINTER, GPOINTER_TO_INT
+#include <gtk/gtk.h>           // for GtkWidget, gtk_button_new_with_label
+#include <stdio.h>             // for NULL
+#include "actions.h"           // for ACTION_TABLE, ActionTable, PROCESS_ACTION
+#include "band.h"              // for canTransmit
+#include "ext.h"               // for ext_vfo_update
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "gpio.h"              // for SWITCH, switches_controller1
+#include "log.h"               // for log_trace
+#include "new_menu.h"          // for start_agc, start_band, start_bandstack
+#include "radio.h"             // for setTune, setMox, getMox, getTune, tran...
+#include "receiver.h"          // for set_offset, RECEIVER
+#include "transmitter.h"       // for transmitter_set_out_of_band
+#include "vfo.h"               // for _vfo, vfo
 
 int function=0;
 
diff --git a/toolbar.h b/toolbar.h
index ea9063a..d0da67f 100644
--- a/toolbar.h
+++ b/toolbar.h
@@ -20,7 +20,10 @@
 #ifndef _TOOLBAR_H
 #define _TOOLBAR_H
 
-#include "gpio.h"
+#include <glib.h>     // for gpointer
+#include <gtk/gtk.h>  // for GtkWidget
+#include "gpio.h"     // for SWITCH
+
 #define MAX_FUNCTION 5
 
 extern int function;
diff --git a/toolbar_menu.c b/toolbar_menu.c
index d0637e6..acafba6 100644
--- a/toolbar_menu.c
+++ b/toolbar_menu.c
@@ -18,27 +18,20 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <glib/gprintf.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "main.h"
-#include "new_menu.h"
-#include "agc_menu.h"
-#include "agc.h"
-#include "band.h"
-#include "channel.h"
-#include "radio.h"
-#include "receiver.h"
-#include "vfo.h"
-#include "button_text.h"
-#include "toolbar.h"
-#include "actions.h"
-#include "action_dialog.h"
-#include "gpio.h"
-#include "i2c.h"
+#include <gdk/gdk.h>           // for GdkEvent
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for gint, gpointer, TRUE, FALSE, gboolean
+#include <glib/gprintf.h>      // for g_sprintf
+#include <glib/gtypes.h>       // for GINT_TO_POINTER, GPOINTER_TO_INT
+#include <gtk/gtk.h>           // for GtkWidget, gtk_button_new_with_label
+#include <stdio.h>             // for NULL
+#include "action_dialog.h"     // for action_dialog
+#include "actions.h"           // for ACTION_TABLE, ActionTable, CONTROLLER_...
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "gpio.h"              // for SWITCH, switches_controller1, MAX_FUNC...
+#include "main.h"              // for top_window
+#include "new_menu.h"          // for sub_menu, NO_MENU, active_menu
+#include "toolbar.h"           // for update_toolbar_labels
 
 static GtkWidget *dialog=NULL;
 static SWITCH *temp_switches;
diff --git a/transmitter.c b/transmitter.c
index eb74d51..5dbdd92 100644
--- a/transmitter.c
+++ b/transmitter.c
@@ -17,36 +17,34 @@
  *
  */
 
-#include <gtk/gtk.h>
-#include <math.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <wdsp.h>
-
-#include "alex.h"
-#include "audio.h"
-#include "band.h"
-#include "bandstack.h"
-#include "channel.h"
-#include "ext.h"
-#include "filter.h"
-#include "log.h"
-#include "main.h"
-#include "meter.h"
-#include "mode.h"
-#include "new_protocol.h"
-#include "old_protocol.h"
-#include "property.h"
-#include "radio.h"
-#include "receiver.h"
-#include "toolbar.h"
 #include "transmitter.h"
-#include "tx_panadapter.h"
-#include "vfo.h"
-#include "vox.h"
-#include "waterfall.h"
+#include <gdk/gdk.h>           // for gdk_threads_add_timeout_full, GDK_KEY_...
+#include <glib-object.h>       // for g_signal_connect, g_object_ref
+#include <glib/gtypes.h>       // for GINT_TO_POINTER
+#include <gtk/gtk.h>           // for gtk_widget_set_size_request, GTK_WINDOW
+#include <math.h>              // for ceil, floor, sin, pow, sqrt
+#include <stdio.h>             // for sprintf, NULL
+#include <stdlib.h>            // for atoi, atof, atoll
+#include <string.h>            // for strcpy, strlen
+#include <wdsp.h>              // for SetTXAPostGenRun, SetTXAAMCarrierLevel
+#include "alex.h"              // for ALEX_TX_ANTENNA_1
+#include "audio.h"             // for cw_audio_write
+#include "discovered.h"        // for NEW_PROTOCOL, ORIGINAL_PROTOCOL, DEVIC...
+#include "ext.h"               // for ext_vfo_update, ext_mox_update
+#include "filter.h"            // for FILTER, filters
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "log.h"               // for log_trace, log_error, log_warn
+#include "main.h"              // for display_width, keypress_cb, display_he...
+#include "meter.h"             // for meter_update, POWER
+#include "mode.h"              // for modeCWL, modeCWU, modeDIGL, modeFMN
+#include "new_protocol.h"      // for new_protocol_iq_samples, new_protocol_...
+#include "old_protocol.h"      // for old_protocol_iq_samples, old_protocol_...
+#include "property.h"          // for getProperty, setProperty
+#include "radio.h"             // for transmitter, protocol, active_receiver
+#include "receiver.h"          // for RECEIVER
+#include "tx_panadapter.h"     // for tx_panadapter_init, tx_panadapter_update
+#include "vfo.h"               // for get_tx_mode, _vfo, vfo
+#include "vox.h"               // for update_vox
 
 double getNextSideToneSample();
 double getNextInternalSideToneSample();
diff --git a/transmitter.h b/transmitter.h
index 2e9fc28..cde0ae0 100644
--- a/transmitter.h
+++ b/transmitter.h
@@ -20,7 +20,9 @@
 #ifndef _TRANSMITTER_H
 #define _TRANSMITTER_H
 
-#include <gtk/gtk.h>
+#include <glib.h>     // for gint, gboolean, gchar
+#include <gtk/gtk.h>  // for GtkWidget
+#include "cairo.h"    // for cairo_surface_t
 
 #define CTCSS_FREQUENCIES 38
 extern double ctcss_frequencies[CTCSS_FREQUENCIES];
diff --git a/tx_menu.c b/tx_menu.c
index de2e19a..ab8d183 100644
--- a/tx_menu.c
+++ b/tx_menu.c
@@ -15,20 +15,23 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "audio.h"
-#include "new_menu.h"
-#include "radio.h"
-#include "sliders.h"
-#include "transmitter.h"
-#include "ext.h"
-#include "filter.h"
-#include "mode.h"
-#include "vfo.h"
+#include <gdk/gdk.h>           // for GdkRGBA, GdkEvent, GdkEventButton
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for gpointer, g_malloc, g_idle_add, g_mall...
+#include <gtk/gtk.h>           // for gtk_grid_attach, gtk_widget_show, GtkW...
+#include <stdio.h>             // for NULL, sprintf
+#include <string.h>            // for strcpy, strlen, strcmp
+#include "audio.h"             // for AUDIO_DEVICE, input_devices, audio_clo...
+#include "discovered.h"        // for NEW_PROTOCOL, ORIGINAL_PROTOCOL, DEVIC...
+#include "ext.h"               // for ext_sliders_update, ext_vfo_update
+#include "filter.h"            // for FILTER, filters
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "mode.h"              // for modeFMN
+#include "new_menu.h"          // for sub_menu
+#include "radio.h"             // for transmitter, tx_filter_high, tx_filter...
+#include "receiver.h"          // for RECEIVER
+#include "transmitter.h"       // for TRANSMITTER, tx_set_filter, transmitte...
+#include "vfo.h"               // for _vfo, vfo
 
 static GtkWidget *parent_window=NULL;
 static GtkWidget *dialog=NULL;
diff --git a/tx_menu.h b/tx_menu.h
index 7920fe3..82427f0 100644
--- a/tx_menu.h
+++ b/tx_menu.h
@@ -14,6 +14,7 @@
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
+#include <gtk/gtk.h>  // for GtkWidget
 
 extern void tx_menu(GtkWidget *parent);
 extern void set_tune(double value);
diff --git a/tx_panadapter.c b/tx_panadapter.c
index 58068c0..b62232c 100644
--- a/tx_panadapter.c
+++ b/tx_panadapter.c
@@ -17,33 +17,24 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <gdk/gdk.h>
-#include <math.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <semaphore.h>
-#include <stdbool.h>
-#include <wdsp.h>
-
-#include "agc.h"
-#include "band.h"
-#include "channel.h"
-#include "discovered.h"
-#include "radio.h"
-#include "receiver.h"
-#include "transmitter.h"
 #include "tx_panadapter.h"
-#include "vfo.h"
-#include "mode.h"
-#include "actions.h"
-#ifdef GPIO
-#include "gpio.h"
-#endif
-#include "ext.h"
-#include "new_menu.h"
-#include "log.h"
+#include <gdk/gdk.h>           // for GdkEventButton, GdkEventMotion, gdk_wi...
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for TRUE, gboolean, FALSE, gpointer, g_idl...
+#include <gtk/gtk.h>           // for gtk_widget_get_allocated_width, GtkWidget
+#include <math.h>              // for floor
+#include <stdio.h>             // for sprintf
+#include <stdlib.h>            // for abs, NULL
+#include "band.h"              // for BAND, band_get_band
+#include "cairo.h"             // for cairo_move_to, cairo_set_source_rgb
+#include "discovered.h"        // for DEVICE_HERMES_LITE2, ORIGINAL_PROTOCOL
+#include "ext.h"               // for ext_start_tx
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "log.h"               // for log_trace
+#include "mode.h"              // for modeCWL, modeCWU
+#include "radio.h"             // for transmitter, cw_keyer_sidetone_frequency
+#include "transmitter.h"       // for TRANSMITTER
+#include "vfo.h"               // for vfo_move, _vfo, vfo, get_tx_mode, get_...
 
 static gint last_x;
 static gboolean has_moved=FALSE;
diff --git a/tx_panadapter.h b/tx_panadapter.h
index dfa8071..3846b2c 100644
--- a/tx_panadapter.h
+++ b/tx_panadapter.h
@@ -20,6 +20,8 @@
 #ifndef _PANADAPTER_H
 #define _PANADAPTER_H
 
+#include "transmitter.h"  // for TRANSMITTER
+
 void tx_panadapter_update(TRANSMITTER *tx);
 
 void tx_panadapter_init(TRANSMITTER *tx,int width,int height);
diff --git a/vfo.c b/vfo.c
index 5626274..31ef51e 100644
--- a/vfo.c
+++ b/vfo.c
@@ -17,44 +17,30 @@
  *
  */
 
-#include <arpa/inet.h>
-#include <ifaddrs.h>
-#include <math.h>
-#include <net/if.h>
-#include <net/if_arp.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <semaphore.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdbool.h>
-#include <gtk/gtk.h>
-
-#include "agc.h"
-#include "band.h"
-#include "bandstack.h"
-#include "channel.h"
-#include "discovered.h"
-#include "filter.h"
-#include "main.h"
-#include "mode.h"
-#include "new_menu.h"
-#include "new_protocol.h"
-#include "property.h"
-#include "radio.h"
-#include "receiver.h"
-#include "rigctl.h"
-#include "toolbar.h"
-#include "transmitter.h"
 #include "vfo.h"
-#include "wdsp.h"
-#ifdef CLIENT_SERVER
-#include "client_server.h"
-#endif
-#include "ext.h"
-#include "screen.h"
-#include "log.h"
+#include <gdk/gdk.h>           // for GdkEventButton, gdk_window_create_simi...
+#include <glib-object.h>       // for g_signal_connect
+#include <gtk/gtk.h>           // for GtkWidget, gtk_drawing_area_new, gtk_w...
+#include <stdio.h>             // for sprintf
+#include <stdlib.h>            // for atoi, malloc, NULL, atoll, free, size_t
+#include <string.h>            // for memset, strncpy, strlen
+#include <sys/types.h>         // for uint
+#include "band.h"              // for BAND, band_get_band, bandstack_get_ban...
+#include "bandstack.h"         // for BANDSTACK_ENTRY, BANDSTACK
+#include "cairo.h"             // for cairo_set_source_rgb, cairo_show_text
+#include "discovered.h"        // for NEW_PROTOCOL
+#include "ext.h"               // for ext_vfo_update, ext_update_noise
+#include "filter.h"            // for FILTER, filterF6, filters
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "log.h"               // for log_trace, log_debug
+#include "mode.h"              // for modeCWU, modeCWL, mode_string, MODES
+#include "new_menu.h"          // for start_vfo
+#include "new_protocol.h"      // for schedule_general, schedule_high_priority
+#include "property.h"          // for getProperty, setProperty
+#include "radio.h"             // for active_receiver, receiver, step, recei...
+#include "receiver.h"          // for RECEIVER, receiver_frequency_changed
+#include "screen.h"            // for widget_props_t, colour_t, default_widg...
+#include "transmitter.h"       // for tx_set_mode, TRANSMITTER
 
 static GtkWidget *parent_window;
 static int my_width;
diff --git a/vfo.h b/vfo.h
index 53246ff..8c3f2d1 100644
--- a/vfo.h
+++ b/vfo.h
@@ -20,7 +20,9 @@
 #ifndef _VFO_H
 #define _VFO_H
 
-#include "mode.h"
+#include <glib.h>         // for gboolean
+#include <glib/gtypes.h>  // for gint64
+#include <gtk/gtk.h>      // for GtkWidget
 
 enum { VFO_A = 0, VFO_B, MAX_VFOS };
 
diff --git a/vfo_menu.c b/vfo_menu.c
index 012307f..8d54876 100644
--- a/vfo_menu.c
+++ b/vfo_menu.c
@@ -17,25 +17,21 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <ctype.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <wdsp.h>
-#include <stdbool.h>
-
-#include "new_menu.h"
-#include "band.h"
-#include "filter.h"
-#include "mode.h"
-#include "radio.h"
-#include "receiver.h"
-#include "transmitter.h"
-#include "vfo.h"
-#include "button_text.h"
-#include "ext.h"
+#include <ctype.h>             // for isdigit
+#include <gdk/gdk.h>           // for GdkRGBA, GdkEvent, GdkEventButton
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for g_idle_add, gpointer, g_malloc, gchar
+#include <gtk/gtk.h>           // for gtk_grid_attach, GtkWidget, gtk_label_...
+#include <stdio.h>             // for sprintf, NULL
+#include <stdlib.h>            // for atof
+#include <string.h>            // for strcmp, strcpy, strlen
+#include "button_text.h"       // for set_button_text_color
+#include "ext.h"               // for ext_vfo_update, ext_set_frequency
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "new_menu.h"          // for sub_menu, NO_MENU, active_menu
+#include "radio.h"             // for locked, rit_increment, active_receiver
+#include "receiver.h"          // for RECEIVER
+#include "vfo.h"               // for SET_FREQUENCY, steps, STEPS, step_labels
 
 static GtkWidget *parent_window=NULL;
 static gint v;
diff --git a/vox.c b/vox.c
index d2b40d2..cfacf29 100644
--- a/vox.c
+++ b/vox.c
@@ -17,14 +17,13 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <stdbool.h>
-
-#include "radio.h"
-#include "transmitter.h"
 #include "vox.h"
-#include "vfo.h"
-#include "ext.h"
+#include <glib.h>         // for g_idle_add, g_source_remove, g_timeout_add
+#include <glib/gtypes.h>  // for GINT_TO_POINTER
+#include <stddef.h>       // for NULL
+#include "ext.h"          // for ext_vfo_update, ext_vox_changed
+#include "radio.h"        // for vox_enabled, vox_hang, vox_threshold
+#include "transmitter.h"  // for TRANSMITTER
 
 static guint vox_timeout=0;
 
diff --git a/vox.h b/vox.h
index 34bd48e..a1d9c4c 100644
--- a/vox.h
+++ b/vox.h
@@ -17,6 +17,8 @@
 *
 */
 
+#include "transmitter.h"  // for TRANSMITTER
+
 extern void update_vox(TRANSMITTER *tx);
 extern void vox_cancel();
 extern double vox_get_peak();
diff --git a/vox_menu.c b/vox_menu.c
index bd8fa30..87479cf 100644
--- a/vox_menu.c
+++ b/vox_menu.c
@@ -17,22 +17,19 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <semaphore.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "led.h"
-#include "new_menu.h"
-#include "radio.h"
-#include "transmitter.h"
-#include "vfo.h"
 #include "vox_menu.h"
-#include "vox.h"
-#include "ext.h"
-#include "log.h"
+#include <glib-object.h>       // for g_signal_connect, G_OBJECT
+#include <glib/gtypes.h>       // for GINT_TO_POINTER
+#include <gtk/gtk.h>           // for gtk_grid_attach, GtkWidget, gtk_widget...
+#include <stdio.h>             // for NULL
+#include <unistd.h>            // for usleep
+#include "ext.h"               // for ext_vfo_update
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "led.h"               // for led_set_color, create_led
+#include "log.h"               // for log_debug
+#include "new_menu.h"          // for sub_menu
+#include "radio.h"             // for vox_enabled, vox_hang, vox_threshold
+#include "vox.h"               // for vox_get_peak
 
 static GtkWidget *parent_window=NULL;
 
diff --git a/vox_menu.h b/vox_menu.h
index 8dfc38d..44af7a5 100644
--- a/vox_menu.h
+++ b/vox_menu.h
@@ -16,6 +16,9 @@
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
+#include <gdk/gdk.h>  // for GdkEventButton
+#include <glib.h>     // for gboolean, gpointer
+#include <gtk/gtk.h>  // for GtkWidget
 
 void vox_menu(GtkWidget *parent);
 gboolean vox_cb (GtkWidget *widget, GdkEventButton *event, gpointer data);
diff --git a/waterfall.c b/waterfall.c
index a117f4b..1f3aa84 100644
--- a/waterfall.c
+++ b/waterfall.c
@@ -17,17 +17,18 @@
  *
  */
 
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-#include <math.h>
-#include <semaphore.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdbool.h>
-
-#include "radio.h"
-#include "vfo.h"
 #include "waterfall.h"
+#include <gdk-pixbuf/gdk-pixbuf.h>  // for gdk_pixbuf_get_pixels, gdk_pixbuf...
+#include <gdk/gdk.h>                // for gdk_cairo_set_source_pixbuf, GdkE...
+#include <glib-object.h>            // for g_signal_connect
+#include <glib.h>                   // for gboolean, gpointer, FALSE, g_mute...
+#include <gtk/gtk.h>                // for GtkWidget, gtk_drawing_area_new
+#include <string.h>                 // for memset, memmove, size_t, NULL
+#include "adc.h"                    // for ADC
+#include "cairo.h"                  // for cairo_paint, cairo_t
+#include "gobject/gclosure.h"       // for G_CALLBACK
+#include "radio.h"                  // for adc, have_rx_gain, rx_gain_calibr...
+#include "vfo.h"                    // for _vfo, vfo
 
 #ifdef CLIENT_SERVER
 #include "client_server.h"
diff --git a/waterfall.h b/waterfall.h
index 3d41f52..b3e2ec0 100644
--- a/waterfall.h
+++ b/waterfall.h
@@ -20,6 +20,8 @@
 #ifndef _WATERFALL_H
 #define _WATERFALL_H
 
+#include "receiver.h"  // for RECEIVER
+
 extern void waterfall_update(RECEIVER *rx);
 extern void waterfall_init(RECEIVER *rx,int width,int height);
 
diff --git a/xvtr_menu.c b/xvtr_menu.c
index 7bd28dc..bc3216d 100644
--- a/xvtr_menu.c
+++ b/xvtr_menu.c
@@ -17,20 +17,24 @@
  *
  */
 
-#include <gtk/gtk.h>
-#include <semaphore.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "band.h"
-#include "filter.h"
-#include "mode.h"
-#include "new_menu.h"
-#include "radio.h"
-#include "vfo.h"
 #include "xvtr_menu.h"
+#include <gdk/gdk.h>           // for GdkRGBA, GdkEvent, GdkEventButton
+#include <glib-object.h>       // for g_signal_connect
+#include <glib.h>              // for FALSE, gpointer, TRUE, gboolean
+#include <glib/gtypes.h>       // for GINT_TO_POINTER, GPOINTER_TO_INT
+#include <gtk/gtk.h>           // for GtkWidget, gtk_grid_attach, gtk_entry_...
+#include <stdio.h>             // for NULL, sprintf
+#include <stdlib.h>            // for atof, atoll
+#include <string.h>            // for strcpy, strlen
+#include "band.h"              // for BAND, band_get_band, BANDS, XVTRS
+#include "bandstack.h"         // for BANDSTACK_ENTRY, BANDSTACK
+#include "filter.h"            // for filterF6
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "mode.h"              // for modeUSB
+#include "new_menu.h"          // for sub_menu
+#include "radio.h"             // for frequency_changed, active_receiver
+#include "receiver.h"          // for RECEIVER
+#include "vfo.h"               // for _vfo, vfo, vfo_xvtr_changed
 
 static GtkWidget *parent_window = NULL;
 static GtkWidget *dialog = NULL;
diff --git a/xvtr_menu.h b/xvtr_menu.h
index 8beb3cc..e45970d 100644
--- a/xvtr_menu.h
+++ b/xvtr_menu.h
@@ -16,5 +16,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
  */
+#include <gtk/gtk.h>  // for GtkWidget
 
 void xvtr_menu(GtkWidget *parent);
diff --git a/zoompan.c b/zoompan.c
index 106f26d..f2ef92c 100644
--- a/zoompan.c
+++ b/zoompan.c
@@ -17,24 +17,21 @@
 *
 */
 
-#include <gtk/gtk.h>
-#include <semaphore.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <stdbool.h>
-
-#include "main.h"
-#include "receiver.h"
-#include "radio.h"
-#include "vfo.h"
-#include "sliders.h"
 #include "zoompan.h"
-#ifdef CLIENT_SERVER
-#include "client_server.h"
-#endif
-#include "actions.h"
-#include "log.h"
+#include <gdk/gdk.h>           // for GdkRGBA
+#include <glib-object.h>       // for g_signal_handler_block, g_signal_handl...
+#include <glib.h>              // for g_print, g_mutex_lock, g_mutex_unlock
+#include <gtk/gtk.h>           // for gtk_range_set_value, GTK_RANGE, gtk_wi...
+#include <stdio.h>             // for NULL, sprintf
+#include "actions.h"           // for PAN, ZOOM
+#include "gobject/gclosure.h"  // for G_CALLBACK
+#include "log.h"               // for log_trace
+#include "main.h"              // for top_window
+#include "pango/pango-font.h"  // for pango_font_description_from_string
+#include "radio.h"             // for active_receiver, receiver, display_zoo...
+#include "receiver.h"          // for RECEIVER, receiver_change_pan, receive...
+#include "sliders.h"           // for scale_status, scale_dialog, scale_time...
+#include "vfo.h"               // for vfo_update
 
 static int width;
 static int height;
diff --git a/zoompan.h b/zoompan.h
index c4f36df..bb50eca 100644
--- a/zoompan.h
+++ b/zoompan.h
@@ -18,6 +18,8 @@
 #ifndef _ZOOMPAN_H
 #define _ZOOMPAN_H
 
+#include <gtk/gtk.h>  // for GtkWidget
+
 #define MAX_ZOOM 8
 
 extern GtkWidget *zoompan_init(int my_width, int my_height);
-- 
2.45.2