GUACAMOLE-249: Add/remove headers as necessary based on run through Include What You Use (IWYU) tool.
diff --git a/src/protocols/rdp/bitmap.c b/src/protocols/rdp/bitmap.c
index 252f66c..61621f2 100644
--- a/src/protocols/rdp/bitmap.c
+++ b/src/protocols/rdp/bitmap.c
@@ -17,21 +17,15 @@
  * under the License.
  */
 
-#include "config.h"
 #include "bitmap.h"
-#include "client.h"
 #include "common/display.h"
 #include "common/surface.h"
 #include "rdp.h"
-#include "settings.h"
 
 #include <cairo/cairo.h>
-#include <freerdp/codec/bitmap.h>
-#include <freerdp/codec/color.h>
 #include <freerdp/freerdp.h>
-#include <freerdp/gdi/gdi.h>
 #include <guacamole/client.h>
-#include <guacamole/socket.h>
+#include <winpr/crt.h>
 #include <winpr/wtypes.h>
 
 #include <stdio.h>
diff --git a/src/protocols/rdp/bitmap.h b/src/protocols/rdp/bitmap.h
index 70068b5..ef3e547 100644
--- a/src/protocols/rdp/bitmap.h
+++ b/src/protocols/rdp/bitmap.h
@@ -24,6 +24,7 @@
 #include "common/display.h"
 
 #include <freerdp/freerdp.h>
+#include <freerdp/graphics.h>
 #include <guacamole/layer.h>
 #include <winpr/wtypes.h>
 
diff --git a/src/protocols/rdp/channels/audio-input.c b/src/protocols/rdp/channels/audio-input.c
index 055ce83..29b4816 100644
--- a/src/protocols/rdp/channels/audio-input.c
+++ b/src/protocols/rdp/channels/audio-input.c
@@ -17,14 +17,13 @@
  * under the License.
  */
 
-#include "config.h"
 #include "channels/audio-input.h"
 #include "plugins/channels.h"
 #include "plugins/ptr-string.h"
 #include "rdp.h"
 
 #include <freerdp/freerdp.h>
-#include <freerdp/channels/channels.h>
+#include <guacamole/client.h>
 #include <guacamole/protocol.h>
 #include <guacamole/socket.h>
 #include <guacamole/stream.h>
@@ -32,8 +31,10 @@
 
 #include <assert.h>
 #include <errno.h>
-#include <stdlib.h>
 #include <pthread.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
 
 /**
  * Parses the given raw audio mimetype, producing the corresponding rate,
diff --git a/src/protocols/rdp/channels/audio-input.h b/src/protocols/rdp/channels/audio-input.h
index 19b6f66..366500a 100644
--- a/src/protocols/rdp/channels/audio-input.h
+++ b/src/protocols/rdp/channels/audio-input.h
@@ -20,12 +20,9 @@
 #ifndef GUAC_RDP_CHANNELS_AUDIO_INPUT_H
 #define GUAC_RDP_CHANNELS_AUDIO_INPUT_H
 
-#include "config.h"
-
 #include <freerdp/freerdp.h>
 #include <guacamole/stream.h>
 #include <guacamole/user.h>
-
 #include <pthread.h>
 
 /**
diff --git a/src/protocols/rdp/channels/cliprdr.c b/src/protocols/rdp/channels/cliprdr.c
index 30e02f7..e62bbb1 100644
--- a/src/protocols/rdp/channels/cliprdr.c
+++ b/src/protocols/rdp/channels/cliprdr.c
@@ -17,8 +17,6 @@
  * under the License.
  */
 
-#include "config.h"
-
 #include "channels/cliprdr.h"
 #include "client.h"
 #include "common/clipboard.h"
@@ -26,10 +24,13 @@
 #include "plugins/channels.h"
 #include "rdp.h"
 
-#include <freerdp/channels/channels.h>
 #include <freerdp/client/cliprdr.h>
+#include <freerdp/event.h>
 #include <freerdp/freerdp.h>
 #include <guacamole/client.h>
+#include <guacamole/stream.h>
+#include <guacamole/user.h>
+#include <winpr/wtsapi.h>
 #include <winpr/wtypes.h>
 
 #include <assert.h>
diff --git a/src/protocols/rdp/channels/cliprdr.h b/src/protocols/rdp/channels/cliprdr.h
index e9b7c9a..4c920bf 100644
--- a/src/protocols/rdp/channels/cliprdr.h
+++ b/src/protocols/rdp/channels/cliprdr.h
@@ -20,12 +20,14 @@
 #ifndef GUAC_RDP_CHANNELS_CLIPRDR_H
 #define GUAC_RDP_CHANNELS_CLIPRDR_H
 
-#include "config.h"
 #include "common/clipboard.h"
 
-#include <guacamole/client.h>
 #include <freerdp/client/cliprdr.h>
+#include <freerdp/freerdp.h>
+#include <guacamole/client.h>
+#include <guacamole/user.h>
 #include <winpr/stream.h>
+#include <winpr/wtypes.h>
 
 /**
  * RDP clipboard, leveraging the "CLIPRDR" channel.
diff --git a/src/protocols/rdp/channels/common-svc.c b/src/protocols/rdp/channels/common-svc.c
index a089bac..20254ad 100644
--- a/src/protocols/rdp/channels/common-svc.c
+++ b/src/protocols/rdp/channels/common-svc.c
@@ -17,19 +17,19 @@
  * under the License.
  */
 
-#include "config.h"
 #include "channels/common-svc.h"
 #include "plugins/channels.h"
 #include "rdp.h"
 
-#include <freerdp/svc.h>
+#include <freerdp/settings.h>
 #include <guacamole/client.h>
-#include <guacamole/stream.h>
 #include <guacamole/string.h>
 #include <winpr/stream.h>
 #include <winpr/wtsapi.h>
 #include <winpr/wtypes.h>
 
+#include <stdlib.h>
+
 int guac_rdp_common_svc_load_plugin(rdpContext* context,
         char* name, ULONG channel_options,
         guac_rdp_common_svc_connect_handler* connect_handler,
diff --git a/src/protocols/rdp/channels/common-svc.h b/src/protocols/rdp/channels/common-svc.h
index 82a9a63..aaa7aab 100644
--- a/src/protocols/rdp/channels/common-svc.h
+++ b/src/protocols/rdp/channels/common-svc.h
@@ -20,8 +20,7 @@
 #ifndef GUAC_RDP_CHANNELS_COMMON_SVC_H
 #define GUAC_RDP_CHANNELS_COMMON_SVC_H
 
-#include "config.h"
-
+#include <freerdp/freerdp.h>
 #include <freerdp/svc.h>
 #include <guacamole/client.h>
 #include <guacamole/stream.h>
@@ -29,6 +28,8 @@
 #include <winpr/wtsapi.h>
 #include <winpr/wtypes.h>
 
+struct guac_rdp_common_svc;
+
 /**
  * The maximum number of bytes to allow within each channel name, including
  * null terminator.
diff --git a/src/protocols/rdp/channels/disp.c b/src/protocols/rdp/channels/disp.c
index d487a04..a25f6fa 100644
--- a/src/protocols/rdp/channels/disp.c
+++ b/src/protocols/rdp/channels/disp.c
@@ -17,18 +17,19 @@
  * under the License.
  */
 
-#include "config.h"
 #include "channels/disp.h"
-#include "client.h"
 #include "plugins/channels.h"
 #include "rdp.h"
 #include "settings.h"
 
 #include <freerdp/client/disp.h>
 #include <freerdp/freerdp.h>
+#include <freerdp/event.h>
 #include <guacamole/client.h>
 #include <guacamole/timestamp.h>
-#include <winpr/wtypes.h>
+
+#include <stdlib.h>
+#include <string.h>
 
 guac_rdp_disp* guac_rdp_disp_alloc() {
 
diff --git a/src/protocols/rdp/channels/pipe-svc.c b/src/protocols/rdp/channels/pipe-svc.c
index 3bf90ed..e918fe7 100644
--- a/src/protocols/rdp/channels/pipe-svc.c
+++ b/src/protocols/rdp/channels/pipe-svc.c
@@ -17,21 +17,21 @@
  * under the License.
  */
 
-#include "config.h"
 #include "channels/common-svc.h"
 #include "channels/pipe-svc.h"
-#include "client.h"
 #include "common/list.h"
-#include "plugins/channels.h"
 #include "rdp.h"
 
-#include <freerdp/svc.h>
+#include <freerdp/settings.h>
 #include <guacamole/client.h>
-#include <guacamole/string.h>
+#include <guacamole/protocol.h>
+#include <guacamole/socket.h>
+#include <guacamole/stream.h>
+#include <guacamole/user.h>
 #include <winpr/stream.h>
-#include <winpr/wtsapi.h>
 
 #include <stdlib.h>
+#include <string.h>
 
 void guac_rdp_pipe_svc_send_pipe(guac_socket* socket, guac_rdp_pipe_svc* pipe_svc) {
 
diff --git a/src/protocols/rdp/channels/pipe-svc.h b/src/protocols/rdp/channels/pipe-svc.h
index 6ab43f9..4ba64be 100644
--- a/src/protocols/rdp/channels/pipe-svc.h
+++ b/src/protocols/rdp/channels/pipe-svc.h
@@ -20,12 +20,14 @@
 #ifndef GUAC_RDP_CHANNELS_PIPE_SVC_H
 #define GUAC_RDP_CHANNELS_PIPE_SVC_H
 
-#include "config.h"
 #include "channels/common-svc.h"
 
+#include <freerdp/freerdp.h>
 #include <freerdp/svc.h>
 #include <guacamole/client.h>
 #include <guacamole/stream.h>
+#include <guacamole/socket.h>
+#include <guacamole/user.h>
 #include <winpr/wtsapi.h>
 
 /**
diff --git a/src/protocols/rdp/channels/rail.c b/src/protocols/rdp/channels/rail.c
index 37017c4..eb645a8 100644
--- a/src/protocols/rdp/channels/rail.c
+++ b/src/protocols/rdp/channels/rail.c
@@ -17,19 +17,21 @@
  * under the License.
  */
 
-#include "config.h"
 #include "channels/rail.h"
-#include "client.h"
 #include "plugins/channels.h"
 #include "rdp.h"
 #include "settings.h"
 
 #include <freerdp/client/rail.h>
+#include <freerdp/event.h>
 #include <freerdp/freerdp.h>
+#include <freerdp/rail.h>
 #include <guacamole/client.h>
 #include <winpr/wtypes.h>
+#include <winpr/wtsapi.h>
 
 #include <stddef.h>
+#include <string.h>
 
 /**
  * Completes initialization of the RemoteApp session, sending client system
diff --git a/src/protocols/rdp/channels/rail.h b/src/protocols/rdp/channels/rail.h
index 9b0d231..0856034 100644
--- a/src/protocols/rdp/channels/rail.h
+++ b/src/protocols/rdp/channels/rail.h
@@ -20,8 +20,6 @@
 #ifndef GUAC_RDP_CHANNELS_RAIL_H
 #define GUAC_RDP_CHANNELS_RAIL_H
 
-#include "config.h"
-
 #include <freerdp/freerdp.h>
 
 /**
diff --git a/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages-dir-info.c b/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages-dir-info.c
index 25d355f..70eb8cd 100644
--- a/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages-dir-info.c
+++ b/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages-dir-info.c
@@ -17,17 +17,18 @@
  * under the License.
  */
 
-#include "config.h"
 #include "channels/rdpdr/rdpdr-fs-messages-dir-info.h"
 #include "channels/rdpdr/rdpdr.h"
 #include "fs.h"
 #include "unicode.h"
 
+#include <guacamole/client.h>
 #include <guacamole/unicode.h>
-#include <winpr/file.h>
+#include <winpr/nt.h>
 #include <winpr/stream.h>
 
 #include <stddef.h>
+#include <stddef.h>
 
 void guac_rdpdr_fs_process_query_directory_info(guac_rdp_common_svc* svc,
         guac_rdpdr_device* device, guac_rdpdr_iorequest* iorequest,
diff --git a/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages-dir-info.h b/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages-dir-info.h
index c4b0f8a..fb49ce9 100644
--- a/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages-dir-info.h
+++ b/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages-dir-info.h
@@ -28,7 +28,6 @@
  * @file rdpdr-fs-messages-dir-info.h
  */
 
-#include "config.h"
 #include "channels/common-svc.h"
 #include "channels/rdpdr/rdpdr.h"
 
diff --git a/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages-file-info.c b/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages-file-info.c
index 0e4f66f..0f45303 100644
--- a/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages-file-info.c
+++ b/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages-file-info.c
@@ -17,18 +17,18 @@
  * under the License.
  */
 
-#include "config.h"
 #include "channels/rdpdr/rdpdr-fs-messages-file-info.h"
 #include "channels/rdpdr/rdpdr.h"
 #include "download.h"
 #include "fs.h"
 #include "unicode.h"
 
+#include <guacamole/client.h>
 #include <winpr/file.h>
+#include <winpr/nt.h>
 #include <winpr/stream.h>
 #include <winpr/wtypes.h>
 
-#include <inttypes.h>
 #include <stdint.h>
 #include <string.h>
 
diff --git a/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages-file-info.h b/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages-file-info.h
index dfd207a..25f13ce 100644
--- a/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages-file-info.h
+++ b/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages-file-info.h
@@ -27,7 +27,6 @@
  * @file rdpdr-fs-messages-file-info.h
  */
 
-#include "config.h"
 #include "channels/common-svc.h"
 #include "channels/rdpdr/rdpdr.h"
 
diff --git a/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages-vol-info.c b/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages-vol-info.c
index 1ab9dd2..0ce4684 100644
--- a/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages-vol-info.c
+++ b/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages-vol-info.c
@@ -17,15 +17,17 @@
  * under the License.
  */
 
-#include "config.h"
-#include "channels/rdpdr/rdpdr-messages.h"
+#include "channels/common-svc.h"
 #include "channels/rdpdr/rdpdr-fs-messages-vol-info.h"
 #include "channels/rdpdr/rdpdr-fs.h"
 #include "channels/rdpdr/rdpdr.h"
 #include "fs.h"
 
+#include <guacamole/client.h>
 #include <guacamole/unicode.h>
 #include <winpr/file.h>
+#include <winpr/io.h>
+#include <winpr/nt.h>
 #include <winpr/stream.h>
 #include <winpr/wtypes.h>
 
diff --git a/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages-vol-info.h b/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages-vol-info.h
index 87c0745..b8c9522 100644
--- a/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages-vol-info.h
+++ b/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages-vol-info.h
@@ -28,7 +28,6 @@
  * @file rdpdr-fs-messages-vol-info.h
  */
 
-#include "config.h"
 #include "channels/rdpdr/rdpdr.h"
 
 #include <winpr/stream.h>
diff --git a/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages.c b/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages.c
index 60fa685..529eea5 100644
--- a/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages.c
+++ b/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages.c
@@ -17,12 +17,11 @@
  * under the License.
  */
 
-#include "config.h"
+#include "channels/common-svc.h"
 #include "channels/rdpdr/rdpdr-fs-messages-dir-info.h"
 #include "channels/rdpdr/rdpdr-fs-messages-file-info.h"
 #include "channels/rdpdr/rdpdr-fs-messages-vol-info.h"
 #include "channels/rdpdr/rdpdr-fs-messages.h"
-#include "channels/rdpdr/rdpdr-messages.h"
 #include "channels/rdpdr/rdpdr.h"
 #include "download.h"
 #include "fs.h"
@@ -30,11 +29,10 @@
 
 #include <freerdp/channels/rdpdr.h>
 #include <guacamole/client.h>
-#include <winpr/file.h>
+#include <winpr/nt.h>
 #include <winpr/stream.h>
 #include <winpr/wtypes.h>
 
-#include <inttypes.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages.h b/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages.h
index bfc8312..63fcbb9 100644
--- a/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages.h
+++ b/src/protocols/rdp/channels/rdpdr/rdpdr-fs-messages.h
@@ -28,7 +28,6 @@
  * @file rdpdr-fs-messages.h
  */
 
-#include "config.h"
 #include "channels/rdpdr/rdpdr.h"
 
 #include <winpr/stream.h>
diff --git a/src/protocols/rdp/channels/rdpdr/rdpdr-fs.c b/src/protocols/rdp/channels/rdpdr/rdpdr-fs.c
index 50f3c28..ed67ac6 100644
--- a/src/protocols/rdp/channels/rdpdr/rdpdr-fs.c
+++ b/src/protocols/rdp/channels/rdpdr/rdpdr-fs.c
@@ -17,20 +17,19 @@
  * under the License.
  */
 
-#include "config.h"
-#include "channels/rdpdr/rdpdr-fs-messages.h"
 #include "channels/rdpdr/rdpdr-fs.h"
-#include "channels/rdpdr/rdpdr-messages.h"
+#include "channels/rdpdr/rdpdr-fs-messages.h"
 #include "channels/rdpdr/rdpdr.h"
 #include "rdp.h"
 
 #include <freerdp/channels/rdpdr.h>
+#include <freerdp/settings.h>
 #include <guacamole/client.h>
-#include <guacamole/protocol.h>
-#include <guacamole/socket.h>
 #include <guacamole/unicode.h>
 #include <winpr/stream.h>
 
+#include <stddef.h>
+
 void guac_rdpdr_device_fs_iorequest_handler(guac_rdp_common_svc* svc,
         guac_rdpdr_device* device, guac_rdpdr_iorequest* iorequest,
         wStream* input_stream) {
diff --git a/src/protocols/rdp/channels/rdpdr/rdpdr-fs.h b/src/protocols/rdp/channels/rdpdr/rdpdr-fs.h
index 6f6e5d1..129fb26 100644
--- a/src/protocols/rdp/channels/rdpdr/rdpdr-fs.h
+++ b/src/protocols/rdp/channels/rdpdr/rdpdr-fs.h
@@ -31,7 +31,7 @@
  * @file rdpdr-fs.h 
  */
 
-#include "config.h"
+#include "channels/common-svc.h"
 #include "channels/rdpdr/rdpdr.h"
 
 #include <guacamole/pool.h>
diff --git a/src/protocols/rdp/channels/rdpdr/rdpdr-messages.c b/src/protocols/rdp/channels/rdpdr/rdpdr-messages.c
index c4d4b03..28a27e6 100644
--- a/src/protocols/rdp/channels/rdpdr/rdpdr-messages.c
+++ b/src/protocols/rdp/channels/rdpdr/rdpdr-messages.c
@@ -17,15 +17,13 @@
  * under the License.
  */
 
-#include "config.h"
 #include "channels/rdpdr/rdpdr-messages.h"
 #include "channels/rdpdr/rdpdr.h"
 #include "rdp.h"
-#include "unicode.h"
+#include "settings.h"
 
 #include <freerdp/channels/rdpdr.h>
 #include <guacamole/client.h>
-#include <guacamole/unicode.h>
 #include <winpr/stream.h>
 
 #include <stdlib.h>
diff --git a/src/protocols/rdp/channels/rdpdr/rdpdr-messages.h b/src/protocols/rdp/channels/rdpdr/rdpdr-messages.h
index 27684cf..a79c83b 100644
--- a/src/protocols/rdp/channels/rdpdr/rdpdr-messages.h
+++ b/src/protocols/rdp/channels/rdpdr/rdpdr-messages.h
@@ -20,7 +20,7 @@
 #ifndef GUAC_RDP_CHANNELS_RDPDR_MESSAGES_H
 #define GUAC_RDP_CHANNELS_RDPDR_MESSAGES_H
 
-#include "config.h"
+#include "channels/common-svc.h"
 #include "channels/rdpdr/rdpdr.h"
 
 #include <winpr/stream.h>
diff --git a/src/protocols/rdp/channels/rdpdr/rdpdr-printer.c b/src/protocols/rdp/channels/rdpdr/rdpdr-printer.c
index e435d32..d90116f 100644
--- a/src/protocols/rdp/channels/rdpdr/rdpdr-printer.c
+++ b/src/protocols/rdp/channels/rdpdr/rdpdr-printer.c
@@ -17,8 +17,6 @@
  * under the License.
  */
 
-#include "config.h"
-#include "channels/rdpdr/rdpdr-messages.h"
 #include "channels/rdpdr/rdpdr-printer.h"
 #include "channels/rdpdr/rdpdr.h"
 #include "print-job.h"
@@ -26,21 +24,13 @@
 #include "unicode.h"
 
 #include <freerdp/channels/rdpdr.h>
+#include <freerdp/settings.h>
 #include <guacamole/client.h>
-#include <guacamole/protocol.h>
-#include <guacamole/socket.h>
-#include <guacamole/stream.h>
 #include <guacamole/unicode.h>
-#include <guacamole/user.h>
-#include <winpr/file.h>
+#include <winpr/nt.h>
 #include <winpr/stream.h>
 
-#include <errno.h>
-#include <pthread.h>
-#include <stdint.h>
 #include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
 
 void guac_rdpdr_process_print_job_create(guac_rdp_common_svc* svc,
         guac_rdpdr_device* device, guac_rdpdr_iorequest* iorequest,
diff --git a/src/protocols/rdp/channels/rdpdr/rdpdr-printer.h b/src/protocols/rdp/channels/rdpdr/rdpdr-printer.h
index 106d6be..a6865d8 100644
--- a/src/protocols/rdp/channels/rdpdr/rdpdr-printer.h
+++ b/src/protocols/rdp/channels/rdpdr/rdpdr-printer.h
@@ -20,7 +20,7 @@
 #ifndef GUAC_RDP_CHANNELS_RDPDR_PRINTER_H
 #define GUAC_RDP_CHANNELS_RDPDR_PRINTER_H
 
-#include "config.h"
+#include "channels/common-svc.h"
 #include "channels/rdpdr/rdpdr.h"
 
 #include <winpr/stream.h>
diff --git a/src/protocols/rdp/channels/rdpdr/rdpdr.c b/src/protocols/rdp/channels/rdpdr/rdpdr.c
index d0d3143..f67a55b 100644
--- a/src/protocols/rdp/channels/rdpdr/rdpdr.c
+++ b/src/protocols/rdp/channels/rdpdr/rdpdr.c
@@ -17,26 +17,20 @@
  * under the License.
  */
 
-#include "config.h"
+#include "channels/rdpdr/rdpdr.h"
 #include "channels/rdpdr/rdpdr-fs.h"
 #include "channels/rdpdr/rdpdr-messages.h"
 #include "channels/rdpdr/rdpdr-printer.h"
-#include "channels/rdpdr/rdpdr.h"
-#include "fs.h"
-#include "plugins/channels.h"
 #include "rdp.h"
 #include "settings.h"
 
 #include <freerdp/channels/rdpdr.h>
 #include <freerdp/freerdp.h>
+#include <freerdp/settings.h>
 #include <guacamole/client.h>
-#include <guacamole/protocol.h>
-#include <guacamole/socket.h>
-#include <guacamole/stream.h>
 #include <winpr/stream.h>
 
 #include <stdlib.h>
-#include <string.h>
 
 void guac_rdpdr_process_receive(guac_rdp_common_svc* svc,
         wStream* input_stream) {
diff --git a/src/protocols/rdp/channels/rdpdr/rdpdr.h b/src/protocols/rdp/channels/rdpdr/rdpdr.h
index fc494ee..b074348 100644
--- a/src/protocols/rdp/channels/rdpdr/rdpdr.h
+++ b/src/protocols/rdp/channels/rdpdr/rdpdr.h
@@ -20,11 +20,15 @@
 #ifndef GUAC_RDP_CHANNELS_RDPDR_H
 #define GUAC_RDP_CHANNELS_RDPDR_H
 
-#include "config.h"
 #include "channels/common-svc.h"
 
 #include <freerdp/freerdp.h>
 #include <guacamole/client.h>
+#include <winpr/stream.h>
+
+#include <stdint.h>
+
+struct guac_rdpdr_device;
 
 /**
  * The maximum number of bytes to allow for a device read.
diff --git a/src/protocols/rdp/channels/rdpsnd/rdpsnd-messages.c b/src/protocols/rdp/channels/rdpsnd/rdpsnd-messages.c
index f0dedaa..1d69e06 100644
--- a/src/protocols/rdp/channels/rdpsnd/rdpsnd-messages.c
+++ b/src/protocols/rdp/channels/rdpsnd/rdpsnd-messages.c
@@ -17,8 +17,6 @@
  * under the License.
  */
 
-#include "config.h"
-
 #include "channels/rdpsnd/rdpsnd-messages.h"
 #include "channels/rdpsnd/rdpsnd.h"
 #include "rdp.h"
@@ -29,8 +27,8 @@
 #include <winpr/stream.h>
 #include <winpr/wtypes.h>
 
-#include <pthread.h>
 #include <stdlib.h>
+#include <string.h>
 
 void guac_rdpsnd_formats_handler(guac_rdp_common_svc* svc,
         wStream* input_stream, guac_rdpsnd_pdu_header* header) {
diff --git a/src/protocols/rdp/channels/rdpsnd/rdpsnd-messages.h b/src/protocols/rdp/channels/rdpsnd/rdpsnd-messages.h
index 3c3733c..9271151 100644
--- a/src/protocols/rdp/channels/rdpsnd/rdpsnd-messages.h
+++ b/src/protocols/rdp/channels/rdpsnd/rdpsnd-messages.h
@@ -20,7 +20,6 @@
 #ifndef GUAC_RDP_CHANNELS_RDPSND_MESSAGES_H
 #define GUAC_RDP_CHANNELS_RDPSND_MESSAGES_H
 
-#include "config.h"
 #include "channels/common-svc.h"
 
 #include <winpr/stream.h>
diff --git a/src/protocols/rdp/channels/rdpsnd/rdpsnd.c b/src/protocols/rdp/channels/rdpsnd/rdpsnd.c
index 5859d4e..be6034d 100644
--- a/src/protocols/rdp/channels/rdpsnd/rdpsnd.c
+++ b/src/protocols/rdp/channels/rdpsnd/rdpsnd.c
@@ -17,16 +17,14 @@
  * under the License.
  */
 
-#include "config.h"
 #include "channels/common-svc.h"
-#include "channels/rdpsnd/rdpsnd-messages.h"
 #include "channels/rdpsnd/rdpsnd.h"
+#include "channels/rdpsnd/rdpsnd-messages.h"
 #include "rdp.h"
 
 #include <freerdp/codec/audio.h>
 #include <freerdp/freerdp.h>
 #include <guacamole/client.h>
-#include <guacamole/client.h>
 #include <winpr/stream.h>
 
 #include <stdlib.h>
diff --git a/src/protocols/rdp/channels/rdpsnd/rdpsnd.h b/src/protocols/rdp/channels/rdpsnd/rdpsnd.h
index 97b6085..cd7fe23 100644
--- a/src/protocols/rdp/channels/rdpsnd/rdpsnd.h
+++ b/src/protocols/rdp/channels/rdpsnd/rdpsnd.h
@@ -20,9 +20,9 @@
 #ifndef GUAC_RDP_CHANNELS_RDPSND_H
 #define GUAC_RDP_CHANNELS_RDPSND_H
 
-#include "config.h"
 #include "channels/common-svc.h"
 
+#include <freerdp/freerdp.h>
 #include <guacamole/client.h>
 
 /**
diff --git a/src/protocols/rdp/client.c b/src/protocols/rdp/client.c
index c8150ac..8cbc163 100644
--- a/src/protocols/rdp/client.c
+++ b/src/protocols/rdp/client.c
@@ -17,14 +17,16 @@
  * under the License.
  */
 
-#include "config.h"
-#include "channels/audio-input.h"
-#include "channels/disp.h"
 #include "client.h"
+#include "channels/audio-input.h"
+#include "channels/cliprdr.h"
+#include "channels/disp.h"
 #include "common/recording.h"
+#include "config.h"
 #include "fs.h"
 #include "log.h"
 #include "rdp.h"
+#include "settings.h"
 #include "user.h"
 
 #ifdef ENABLE_COMMON_SSH
@@ -33,19 +35,11 @@
 #include "common-ssh/user.h"
 #endif
 
-#include <freerdp/cache/cache.h>
-#include <freerdp/channels/channels.h>
-#include <freerdp/client/channels.h>
-#include <freerdp/client/cliprdr.h>
-#include <freerdp/freerdp.h>
 #include <guacamole/audio.h>
 #include <guacamole/client.h>
-#include <guacamole/socket.h>
-#include <winpr/wlog.h>
 
 #include <pthread.h>
 #include <stdlib.h>
-#include <string.h>
 
 int guac_client_init(guac_client* client, int argc, char** argv) {
 
diff --git a/src/protocols/rdp/client.h b/src/protocols/rdp/client.h
index 4f6c266..9acd33a 100644
--- a/src/protocols/rdp/client.h
+++ b/src/protocols/rdp/client.h
@@ -20,8 +20,6 @@
 #ifndef GUAC_RDP_CLIENT_H
 #define GUAC_RDP_CLIENT_H
 
-#include "config.h"
-
 #include <guacamole/client.h>
 
 /**
diff --git a/src/protocols/rdp/color.c b/src/protocols/rdp/color.c
index c7db078..cfe8d34 100644
--- a/src/protocols/rdp/color.c
+++ b/src/protocols/rdp/color.c
@@ -17,10 +17,6 @@
  * under the License.
  */
 
-#include "config.h"
-
-#include "client.h"
-#include "rdp.h"
 #include "settings.h"
 
 #include <freerdp/codec/color.h>
@@ -28,6 +24,8 @@
 #include <freerdp/gdi/gdi.h>
 #include <winpr/wtypes.h>
 
+#include <stdint.h>
+
 UINT32 guac_rdp_get_native_pixel_format(BOOL alpha) {
 
     uint8_t color[] = { 0x0A, 0x0B, 0x0C, 0x0D };
diff --git a/src/protocols/rdp/decompose.c b/src/protocols/rdp/decompose.c
index 5f559d9..e42a769 100644
--- a/src/protocols/rdp/decompose.c
+++ b/src/protocols/rdp/decompose.c
@@ -17,7 +17,6 @@
  * under the License.
  */
 
-#include "config.h"
 #include "keyboard.h"
 
 /**
diff --git a/src/protocols/rdp/download.c b/src/protocols/rdp/download.c
index 34f7e2e..ceb211e 100644
--- a/src/protocols/rdp/download.c
+++ b/src/protocols/rdp/download.c
@@ -17,23 +17,21 @@
  * under the License.
  */
 
-#include "config.h"
-#include "client.h"
+#include "common/json.h"
 #include "download.h"
 #include "fs.h"
 #include "ls.h"
 #include "rdp.h"
 
-#include <freerdp/channels/channels.h>
-#include <freerdp/client/cliprdr.h>
-#include <freerdp/freerdp.h>
 #include <guacamole/client.h>
+#include <guacamole/object.h>
 #include <guacamole/protocol.h>
 #include <guacamole/socket.h>
 #include <guacamole/stream.h>
 #include <guacamole/string.h>
-#include <winpr/stream.h>
-#include <winpr/wtypes.h>
+#include <guacamole/user.h>
+#include <winpr/nt.h>
+#include <winpr/shell.h>
 
 #include <stdlib.h>
 
diff --git a/src/protocols/rdp/download.h b/src/protocols/rdp/download.h
index c15dba6..2989658 100644
--- a/src/protocols/rdp/download.h
+++ b/src/protocols/rdp/download.h
@@ -20,12 +20,11 @@
 #ifndef GUAC_RDP_DOWNLOAD_H
 #define GUAC_RDP_DOWNLOAD_H
 
-#include "config.h"
 #include "common/json.h"
 
-#include <guacamole/user.h>
 #include <guacamole/protocol.h>
 #include <guacamole/stream.h>
+#include <guacamole/user.h>
 
 #include <stdint.h>
 
diff --git a/src/protocols/rdp/error.c b/src/protocols/rdp/error.c
index 0fbc6de..de0e1cd 100644
--- a/src/protocols/rdp/error.c
+++ b/src/protocols/rdp/error.c
@@ -17,7 +17,6 @@
  * under the License.
  */
 
-#include "config.h"
 #include "error.h"
 #include "rdp.h"
 
diff --git a/src/protocols/rdp/fs.c b/src/protocols/rdp/fs.c
index 8b48b94..74664b4 100644
--- a/src/protocols/rdp/fs.c
+++ b/src/protocols/rdp/fs.c
@@ -17,19 +17,19 @@
  * under the License.
  */
 
-#include "config.h"
-
-#include "download.h"
 #include "fs.h"
+#include "download.h"
 #include "upload.h"
 
 #include <guacamole/client.h>
 #include <guacamole/object.h>
 #include <guacamole/pool.h>
+#include <guacamole/protocol.h>
 #include <guacamole/socket.h>
 #include <guacamole/string.h>
 #include <guacamole/user.h>
 #include <winpr/file.h>
+#include <winpr/nt.h>
 
 #include <dirent.h>
 #include <errno.h>
@@ -40,7 +40,6 @@
 #include <string.h>
 #include <sys/stat.h>
 #include <sys/statvfs.h>
-#include <sys/types.h>
 #include <unistd.h>
 
 guac_rdp_fs* guac_rdp_fs_alloc(guac_client* client, const char* drive_path,
diff --git a/src/protocols/rdp/fs.h b/src/protocols/rdp/fs.h
index 168f2df..56c134f 100644
--- a/src/protocols/rdp/fs.h
+++ b/src/protocols/rdp/fs.h
@@ -31,10 +31,10 @@
  * @file fs.h 
  */
 
-#include "config.h"
-
 #include <guacamole/client.h>
+#include <guacamole/object.h>
 #include <guacamole/pool.h>
+#include <guacamole/user.h>
 
 #include <dirent.h>
 #include <stdint.h>
diff --git a/src/protocols/rdp/gdi.c b/src/protocols/rdp/gdi.c
index 98502c8..feb6505 100644
--- a/src/protocols/rdp/gdi.c
+++ b/src/protocols/rdp/gdi.c
@@ -17,21 +17,22 @@
  * under the License.
  */
 
-#include "config.h"
 #include "bitmap.h"
-#include "client.h"
-#include "color.h"
+#include "common/display.h"
 #include "common/surface.h"
 #include "rdp.h"
 #include "settings.h"
 
 #include <cairo/cairo.h>
 #include <freerdp/freerdp.h>
+#include <freerdp/graphics.h>
+#include <freerdp/primary.h>
 #include <guacamole/client.h>
 #include <guacamole/protocol.h>
 #include <winpr/wtypes.h>
 
 #include <stddef.h>
+#include <stddef.h>
 
 guac_transfer_function guac_rdp_rop3_transfer_function(guac_client* client,
         int rop3) {
diff --git a/src/protocols/rdp/glyph.c b/src/protocols/rdp/glyph.c
index 3050c65..cecaa8d 100644
--- a/src/protocols/rdp/glyph.c
+++ b/src/protocols/rdp/glyph.c
@@ -17,19 +17,16 @@
  * under the License.
  */
 
-#include "config.h"
-#include "client.h"
 #include "color.h"
 #include "common/surface.h"
+#include "config.h"
 #include "glyph.h"
 #include "rdp.h"
-#include "settings.h"
 
 #include <freerdp/freerdp.h>
 #include <guacamole/client.h>
 #include <winpr/wtypes.h>
 
-#include <pthread.h>
 #include <stdint.h>
 #include <stdlib.h>
 
diff --git a/src/protocols/rdp/glyph.h b/src/protocols/rdp/glyph.h
index 0d4bf7b..1e9b389 100644
--- a/src/protocols/rdp/glyph.h
+++ b/src/protocols/rdp/glyph.h
@@ -20,10 +20,9 @@
 #ifndef GUAC_RDP_GLYPH_H
 #define GUAC_RDP_GLYPH_H
 
-#include "config.h"
-
 #include <cairo/cairo.h>
 #include <freerdp/freerdp.h>
+#include <freerdp/graphics.h>
 #include <winpr/wtypes.h>
 
 /**
diff --git a/src/protocols/rdp/input.c b/src/protocols/rdp/input.c
index 5e08dd6..8f77dc0 100644
--- a/src/protocols/rdp/input.c
+++ b/src/protocols/rdp/input.c
@@ -17,19 +17,20 @@
  * under the License.
  */
 
-#include "config.h"
 #include "channels/disp.h"
-#include "client.h"
+#include "common/cursor.h"
+#include "common/display.h"
 #include "common/recording.h"
 #include "input.h"
 #include "keyboard.h"
 #include "rdp.h"
+#include "settings.h"
 
 #include <freerdp/freerdp.h>
 #include <freerdp/input.h>
 #include <guacamole/client.h>
+#include <guacamole/user.h>
 
-#include <pthread.h>
 #include <stdlib.h>
 
 int guac_rdp_user_mouse_handler(guac_user* user, int x, int y, int mask) {
diff --git a/src/protocols/rdp/keyboard.c b/src/protocols/rdp/keyboard.c
index 71aba14..42cc4db 100644
--- a/src/protocols/rdp/keyboard.c
+++ b/src/protocols/rdp/keyboard.c
@@ -17,8 +17,6 @@
  * under the License.
  */
 
-#include "config.h"
-#include "client.h"
 #include "decompose.h"
 #include "keyboard.h"
 #include "keymap.h"
@@ -28,7 +26,6 @@
 #include <freerdp/input.h>
 #include <guacamole/client.h>
 
-#include <pthread.h>
 #include <stdlib.h>
 
 /**
diff --git a/src/protocols/rdp/keymap.c b/src/protocols/rdp/keymap.c
index 04b1409..b71b402 100644
--- a/src/protocols/rdp/keymap.c
+++ b/src/protocols/rdp/keymap.c
@@ -17,8 +17,6 @@
  * under the License.
  */
 
-#include "config.h"
-
 #include "keymap.h"
 
 #include <string.h>
diff --git a/src/protocols/rdp/keymap.h b/src/protocols/rdp/keymap.h
index 9e4958c..6ec627f 100644
--- a/src/protocols/rdp/keymap.h
+++ b/src/protocols/rdp/keymap.h
@@ -20,10 +20,10 @@
 #ifndef GUAC_RDP_KEYMAP_H
 #define GUAC_RDP_KEYMAP_H
 
-#include "config.h"
-
 #include <winpr/wtypes.h>
 
+struct guac_rdp_keymap;
+
 /**
  * Represents a keysym-to-scancode mapping for RDP, with extra information
  * about the state of prerequisite keysyms.
diff --git a/src/protocols/rdp/log.c b/src/protocols/rdp/log.c
index fa0a074..29414c1 100644
--- a/src/protocols/rdp/log.c
+++ b/src/protocols/rdp/log.c
@@ -19,6 +19,9 @@
 
 #include <guacamole/client.h>
 #include <winpr/wlog.h>
+#include <winpr/wtypes.h>
+
+#include <stddef.h>
 
 /**
  * The guac_client that should be used within this process for FreeRDP log
diff --git a/src/protocols/rdp/ls.c b/src/protocols/rdp/ls.c
index f008da9..300bf93 100644
--- a/src/protocols/rdp/ls.c
+++ b/src/protocols/rdp/ls.c
@@ -17,24 +17,19 @@
  * under the License.
  */
 
-#include "config.h"
-#include "client.h"
 #include "fs.h"
 #include "ls.h"
-#include "rdp.h"
 
-#include <freerdp/channels/channels.h>
-#include <freerdp/client/cliprdr.h>
-#include <freerdp/freerdp.h>
 #include <guacamole/client.h>
 #include <guacamole/protocol.h>
 #include <guacamole/socket.h>
 #include <guacamole/stream.h>
-#include <guacamole/string.h>
-#include <winpr/stream.h>
-#include <winpr/wtypes.h>
+#include <guacamole/user.h>
+#include <winpr/nt.h>
+#include <winpr/shell.h>
 
 #include <stdlib.h>
+#include <string.h>
 
 int guac_rdp_ls_ack_handler(guac_user* user, guac_stream* stream,
         char* message, guac_protocol_status status) {
diff --git a/src/protocols/rdp/ls.h b/src/protocols/rdp/ls.h
index 21a2eb8..be6a10c 100644
--- a/src/protocols/rdp/ls.h
+++ b/src/protocols/rdp/ls.h
@@ -20,12 +20,12 @@
 #ifndef GUAC_RDP_LS_H
 #define GUAC_RDP_LS_H
 
-#include "config.h"
 #include "common/json.h"
+#include "fs.h"
 
-#include <guacamole/user.h>
 #include <guacamole/protocol.h>
 #include <guacamole/stream.h>
+#include <guacamole/user.h>
 
 #include <stdint.h>
 
diff --git a/src/protocols/rdp/plugins/channels.c b/src/protocols/rdp/plugins/channels.c
index 9cf5a36..a183b66 100644
--- a/src/protocols/rdp/plugins/channels.c
+++ b/src/protocols/rdp/plugins/channels.c
@@ -17,13 +17,16 @@
  * under the License.
  */
 
-#include "config.h"
 #include "plugins/channels.h"
-#include "rdp.h"
 
 #include <freerdp/channels/channels.h>
 #include <freerdp/freerdp.h>
-#include <guacamole/client.h>
+#include <freerdp/addin.h>
+#include <winpr/wtypes.h>
+
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
 
 int guac_rdp_wrapped_entry_ex_count = 0;
 
diff --git a/src/protocols/rdp/plugins/channels.h b/src/protocols/rdp/plugins/channels.h
index f324f87..59d6c82 100644
--- a/src/protocols/rdp/plugins/channels.h
+++ b/src/protocols/rdp/plugins/channels.h
@@ -20,10 +20,10 @@
 #ifndef GUAC_RDP_PLUGINS_CHANNELS_H
 #define GUAC_RDP_PLUGINS_CHANNELS_H
 
-#include "config.h"
-
 #include <freerdp/channels/channels.h>
 #include <freerdp/freerdp.h>
+#include <freerdp/settings.h>
+#include <winpr/wtsapi.h>
 
 /**
  * The maximum number of static channels supported by Guacamole's RDP support.
diff --git a/src/protocols/rdp/plugins/guac-common-svc/guac-common-svc.c b/src/protocols/rdp/plugins/guac-common-svc/guac-common-svc.c
index c55b606..fbba484 100644
--- a/src/protocols/rdp/plugins/guac-common-svc/guac-common-svc.c
+++ b/src/protocols/rdp/plugins/guac-common-svc/guac-common-svc.c
@@ -17,19 +17,15 @@
  * under the License.
  */
 
-#include "config.h"
 #include "channels/common-svc.h"
 
-#include <freerdp/constants.h>
+#include <freerdp/svc.h>
 #include <guacamole/client.h>
-#include <guacamole/protocol.h>
-#include <guacamole/socket.h>
-#include <guacamole/string.h>
 #include <winpr/stream.h>
+#include <winpr/wtsapi.h>
 #include <winpr/wtypes.h>
 
 #include <stdlib.h>
-#include <string.h>
 
 /**
  * Event handler for events which deal with data transmitted over an open SVC.
diff --git a/src/protocols/rdp/plugins/guacai/guacai-messages.c b/src/protocols/rdp/plugins/guacai/guacai-messages.c
index bb759e5..9e4b414 100644
--- a/src/protocols/rdp/plugins/guacai/guacai-messages.c
+++ b/src/protocols/rdp/plugins/guacai/guacai-messages.c
@@ -17,14 +17,11 @@
  * under the License.
  */
 
-#include "config.h"
 #include "channels/audio-input.h"
 #include "plugins/guacai/guacai-messages.h"
 #include "rdp.h"
 
-#include <freerdp/constants.h>
 #include <freerdp/dvc.h>
-#include <freerdp/freerdp.h>
 #include <guacamole/client.h>
 #include <winpr/stream.h>
 
diff --git a/src/protocols/rdp/plugins/guacai/guacai-messages.h b/src/protocols/rdp/plugins/guacai/guacai-messages.h
index 91173c3..49fbd1c 100644
--- a/src/protocols/rdp/plugins/guacai/guacai-messages.h
+++ b/src/protocols/rdp/plugins/guacai/guacai-messages.h
@@ -20,11 +20,12 @@
 #ifndef GUAC_RDP_PLUGINS_GUACAI_MESSAGES_H
 #define GUAC_RDP_PLUGINS_GUACAI_MESSAGES_H
 
-#include "config.h"
+#include "channels/audio-input.h"
 
 #include <freerdp/dvc.h>
 #include <guacamole/client.h>
 #include <winpr/stream.h>
+#include <winpr/wtypes.h>
 
 /**
  * The format tag associated with raw wave audio (WAVE_FORMAT_PCM). This format
diff --git a/src/protocols/rdp/plugins/guacai/guacai.c b/src/protocols/rdp/plugins/guacai/guacai.c
index de9dfb9..80dd87f 100644
--- a/src/protocols/rdp/plugins/guacai/guacai.c
+++ b/src/protocols/rdp/plugins/guacai/guacai.c
@@ -17,21 +17,20 @@
  * under the License.
  */
 
-#include "config.h"
 #include "channels/audio-input.h"
-#include "plugins/guacai/guacai-messages.h"
 #include "plugins/guacai/guacai.h"
+#include "plugins/guacai/guacai-messages.h"
 #include "plugins/ptr-string.h"
 #include "rdp.h"
 
-#include <freerdp/constants.h>
 #include <freerdp/dvc.h>
-#include <freerdp/freerdp.h>
+#include <freerdp/settings.h>
 #include <guacamole/client.h>
 #include <winpr/stream.h>
+#include <winpr/wtsapi.h>
+#include <winpr/wtypes.h>
 
 #include <stdlib.h>
-#include <string.h>
 
 /**
  * Handles the given data received along the AUDIO_INPUT channel of the RDP
diff --git a/src/protocols/rdp/plugins/guacai/guacai.h b/src/protocols/rdp/plugins/guacai/guacai.h
index dacf531..d26563c 100644
--- a/src/protocols/rdp/plugins/guacai/guacai.h
+++ b/src/protocols/rdp/plugins/guacai/guacai.h
@@ -20,8 +20,6 @@
 #ifndef GUAC_RDP_PLUGINS_GUACAI_H
 #define GUAC_RDP_PLUGINS_GUACAI_H
 
-#include "config.h"
-
 #include <freerdp/constants.h>
 #include <freerdp/dvc.h>
 #include <freerdp/freerdp.h>
diff --git a/src/protocols/rdp/plugins/ptr-string.c b/src/protocols/rdp/plugins/ptr-string.c
index 9131187..324a519 100644
--- a/src/protocols/rdp/plugins/ptr-string.c
+++ b/src/protocols/rdp/plugins/ptr-string.c
@@ -17,13 +17,9 @@
  * under the License.
  */
 
-#include "config.h"
 #include "plugins/ptr-string.h"
 
-#include <guacamole/client.h>
-
 #include <stdio.h>
-#include <stdlib.h>
 
 void guac_rdp_ptr_to_string(void* data, char* str) {
 
diff --git a/src/protocols/rdp/plugins/ptr-string.h b/src/protocols/rdp/plugins/ptr-string.h
index bcc226c..ef682b1 100644
--- a/src/protocols/rdp/plugins/ptr-string.h
+++ b/src/protocols/rdp/plugins/ptr-string.h
@@ -20,8 +20,6 @@
 #ifndef GUAC_RDP_PLUGINS_PTR_STRING_H
 #define GUAC_RDP_PLUGINS_PTR_STRING_H
 
-#include "config.h"
-
 #include <guacamole/client.h>
 
 /**
diff --git a/src/protocols/rdp/pointer.c b/src/protocols/rdp/pointer.c
index 41fa5f4..9f66c6a 100644
--- a/src/protocols/rdp/pointer.c
+++ b/src/protocols/rdp/pointer.c
@@ -17,20 +17,19 @@
  * under the License.
  */
 
-#include "config.h"
-#include "client.h"
 #include "color.h"
 #include "common/cursor.h"
 #include "common/display.h"
+#include "common/surface.h"
 #include "pointer.h"
 #include "rdp.h"
 
 #include <cairo/cairo.h>
+#include <freerdp/codec/color.h>
 #include <freerdp/freerdp.h>
 #include <freerdp/gdi/gdi.h>
 #include <guacamole/client.h>
-
-#include <stdlib.h>
+#include <winpr/crt.h>
 
 BOOL guac_rdp_pointer_new(rdpContext* context, rdpPointer* pointer) {
 
diff --git a/src/protocols/rdp/pointer.h b/src/protocols/rdp/pointer.h
index c5ba319..b5fa6a2 100644
--- a/src/protocols/rdp/pointer.h
+++ b/src/protocols/rdp/pointer.h
@@ -20,10 +20,11 @@
 #ifndef GUAC_RDP_POINTER_H
 #define GUAC_RDP_POINTER_H
 
-#include "config.h"
 #include "common/display.h"
 
 #include <freerdp/freerdp.h>
+#include <freerdp/graphics.h>
+#include <winpr/wtypes.h>
 
 /**
  * Guacamole-specific rdpPointer data.
diff --git a/src/protocols/rdp/print-job.c b/src/protocols/rdp/print-job.c
index fed49bb..5a75c6e 100644
--- a/src/protocols/rdp/print-job.c
+++ b/src/protocols/rdp/print-job.c
@@ -17,7 +17,6 @@
  * under the License.
  */
 
-#include "config.h"
 #include "print-job.h"
 
 #include <guacamole/client.h>
diff --git a/src/protocols/rdp/print-job.h b/src/protocols/rdp/print-job.h
index 98897ec..fb990a8 100644
--- a/src/protocols/rdp/print-job.h
+++ b/src/protocols/rdp/print-job.h
@@ -20,8 +20,6 @@
 #ifndef GUAC_RDP_PRINT_JOB_H
 #define GUAC_RDP_PRINT_JOB_H
 
-#include "config.h"
-
 #include <guacamole/client.h>
 #include <guacamole/stream.h>
 #include <guacamole/user.h>
diff --git a/src/protocols/rdp/rdp.c b/src/protocols/rdp/rdp.c
index 49795f1..45914b2 100644
--- a/src/protocols/rdp/rdp.c
+++ b/src/protocols/rdp/rdp.c
@@ -17,7 +17,6 @@
  * under the License.
  */
 
-#include "config.h"
 #include "bitmap.h"
 #include "channels/audio-input.h"
 #include "channels/cliprdr.h"
@@ -31,6 +30,7 @@
 #include "common/cursor.h"
 #include "common/display.h"
 #include "common/recording.h"
+#include "config.h"
 #include "error.h"
 #include "fs.h"
 #include "gdi.h"
@@ -56,26 +56,22 @@
 #include <freerdp/cache/pointer.h>
 #include <freerdp/channels/channels.h>
 #include <freerdp/client/channels.h>
-#include <freerdp/client/cliprdr.h>
-#include <freerdp/client/disp.h>
-#include <freerdp/event.h>
 #include <freerdp/freerdp.h>
 #include <freerdp/gdi/gdi.h>
-#include <freerdp/rail.h>
-#include <freerdp/version.h>
+#include <freerdp/graphics.h>
+#include <freerdp/primary.h>
+#include <freerdp/settings.h>
+#include <freerdp/update.h>
 #include <guacamole/audio.h>
 #include <guacamole/client.h>
 #include <guacamole/protocol.h>
 #include <guacamole/socket.h>
 #include <guacamole/timestamp.h>
+#include <winpr/error.h>
+#include <winpr/synch.h>
 #include <winpr/wtypes.h>
 
-#include <errno.h>
-#include <poll.h>
-#include <pthread.h>
 #include <stdlib.h>
-#include <string.h>
-#include <sys/time.h>
 #include <time.h>
 
 BOOL rdp_freerdp_pre_connect(freerdp* instance) {
diff --git a/src/protocols/rdp/rdp.h b/src/protocols/rdp/rdp.h
index d50b8d2..43f6dc2 100644
--- a/src/protocols/rdp/rdp.h
+++ b/src/protocols/rdp/rdp.h
@@ -20,7 +20,6 @@
 #ifndef GUAC_RDP_H
 #define GUAC_RDP_H
 
-#include "config.h"
 #include "channels/audio-input.h"
 #include "channels/cliprdr.h"
 #include "channels/disp.h"
@@ -29,22 +28,24 @@
 #include "common/list.h"
 #include "common/recording.h"
 #include "common/surface.h"
+#include "config.h"
 #include "fs.h"
 #include "keyboard.h"
 #include "print-job.h"
 #include "settings.h"
 
-#include <freerdp/freerdp.h>
-#include <freerdp/codec/color.h>
-#include <guacamole/audio.h>
-#include <guacamole/client.h>
-
 #ifdef ENABLE_COMMON_SSH
 #include "common-ssh/sftp.h"
 #include "common-ssh/ssh.h"
 #include "common-ssh/user.h"
 #endif
 
+#include <freerdp/codec/color.h>
+#include <freerdp/freerdp.h>
+#include <guacamole/audio.h>
+#include <guacamole/client.h>
+#include <winpr/wtypes.h>
+
 #include <pthread.h>
 #include <stdint.h>
 
diff --git a/src/protocols/rdp/settings.c b/src/protocols/rdp/settings.c
index 872f14f..97e9daf 100644
--- a/src/protocols/rdp/settings.c
+++ b/src/protocols/rdp/settings.c
@@ -17,21 +17,23 @@
  * under the License.
  */
 
-#include "config.h"
-#include "client.h"
 #include "common/string.h"
-#include "rdp.h"
+#include "config.h"
 #include "resolution.h"
 #include "settings.h"
 
 #include <freerdp/constants.h>
 #include <freerdp/settings.h>
+#include <freerdp/freerdp.h>
+#include <guacamole/client.h>
 #include <guacamole/string.h>
 #include <guacamole/user.h>
+#include <winpr/crt.h>
 #include <winpr/wtypes.h>
 
 #include <errno.h>
 #include <stddef.h>
+#include <stdlib.h>
 #include <string.h>
 
 /* Client plugin arguments */
diff --git a/src/protocols/rdp/settings.h b/src/protocols/rdp/settings.h
index 6d72bbb..0935f84 100644
--- a/src/protocols/rdp/settings.h
+++ b/src/protocols/rdp/settings.h
@@ -21,10 +21,10 @@
 #define GUAC_RDP_SETTINGS_H
 
 #include "config.h"
-
 #include "keymap.h"
 
 #include <freerdp/freerdp.h>
+#include <guacamole/client.h>
 #include <guacamole/user.h>
 
 /**
diff --git a/src/protocols/rdp/sftp.c b/src/protocols/rdp/sftp.c
index ecfe35f..0fc2580 100644
--- a/src/protocols/rdp/sftp.c
+++ b/src/protocols/rdp/sftp.c
@@ -17,14 +17,11 @@
  * under the License.
  */
 
-#include "config.h"
-
 #include "common-ssh/sftp.h"
 #include "rdp.h"
 #include "sftp.h"
 
 #include <guacamole/client.h>
-#include <guacamole/stream.h>
 #include <guacamole/user.h>
 
 int guac_rdp_sftp_file_handler(guac_user* user, guac_stream* stream,
diff --git a/src/protocols/rdp/sftp.h b/src/protocols/rdp/sftp.h
index d768324..3f7f9e2 100644
--- a/src/protocols/rdp/sftp.h
+++ b/src/protocols/rdp/sftp.h
@@ -20,8 +20,6 @@
 #ifndef GUAC_RDP_SFTP_H
 #define GUAC_RDP_SFTP_H
 
-#include "config.h"
-
 #include <guacamole/stream.h>
 #include <guacamole/user.h>
 
diff --git a/src/protocols/rdp/unicode.c b/src/protocols/rdp/unicode.c
index 5369f4c..f055bea 100644
--- a/src/protocols/rdp/unicode.c
+++ b/src/protocols/rdp/unicode.c
@@ -17,8 +17,6 @@
  * under the License.
  */
 
-#include "config.h"
-
 #include <guacamole/unicode.h>
 
 #include <stdint.h>
diff --git a/src/protocols/rdp/upload.c b/src/protocols/rdp/upload.c
index 24295ec..07cb8ca 100644
--- a/src/protocols/rdp/upload.c
+++ b/src/protocols/rdp/upload.c
@@ -17,22 +17,17 @@
  * under the License.
  */
 
-#include "config.h"
-#include "client.h"
 #include "fs.h"
 #include "rdp.h"
 #include "upload.h"
 
-#include <freerdp/channels/channels.h>
-#include <freerdp/client/cliprdr.h>
-#include <freerdp/freerdp.h>
 #include <guacamole/client.h>
+#include <guacamole/object.h>
 #include <guacamole/protocol.h>
 #include <guacamole/socket.h>
 #include <guacamole/stream.h>
-#include <guacamole/string.h>
-#include <winpr/stream.h>
-#include <winpr/wtypes.h>
+#include <guacamole/user.h>
+#include <winpr/nt.h>
 
 #include <stdlib.h>
 
diff --git a/src/protocols/rdp/upload.h b/src/protocols/rdp/upload.h
index b7563ff..254538f 100644
--- a/src/protocols/rdp/upload.h
+++ b/src/protocols/rdp/upload.h
@@ -20,12 +20,11 @@
 #ifndef GUAC_RDP_UPLOAD_H
 #define GUAC_RDP_UPLOAD_H
 
-#include "config.h"
 #include "common/json.h"
 
-#include <guacamole/user.h>
 #include <guacamole/protocol.h>
 #include <guacamole/stream.h>
+#include <guacamole/user.h>
 
 #include <stdint.h>
 
diff --git a/src/protocols/rdp/user.c b/src/protocols/rdp/user.c
index b070b4a..2e96b9a 100644
--- a/src/protocols/rdp/user.c
+++ b/src/protocols/rdp/user.c
@@ -17,10 +17,12 @@
  * under the License.
  */
 
-#include "config.h"
 #include "channels/audio-input.h"
+#include "channels/cliprdr.h"
 #include "channels/pipe-svc.h"
+#include "common/cursor.h"
 #include "common/display.h"
+#include "config.h"
 #include "input.h"
 #include "rdp.h"
 #include "settings.h"
@@ -35,9 +37,11 @@
 #include <guacamole/client.h>
 #include <guacamole/protocol.h>
 #include <guacamole/socket.h>
+#include <guacamole/stream.h>
 #include <guacamole/user.h>
 
 #include <pthread.h>
+#include <stddef.h>
 
 int guac_rdp_user_join_handler(guac_user* user, int argc, char** argv) {