diff --git a/Marlin/src/Marlin.cpp b/Marlin/src/Marlin.cpp
index 51de309d3ec43cd7387cb359b990953b20ab3830..3cb9136314f50e0c6b9d3c1b1ad585d1f4bcafd8 100644
--- a/Marlin/src/Marlin.cpp
+++ b/Marlin/src/Marlin.cpp
@@ -186,15 +186,6 @@ static millis_t stepper_inactive_time = (DEFAULT_STEPPER_DEACTIVE_TIME) * 1000UL
   ;
 #endif
 
-#if ENABLED(FILAMENT_WIDTH_SENSOR)
-  bool filament_sensor = false;                                 // M405 turns on filament sensor control. M406 turns it off.
-  float filament_width_nominal = DEFAULT_NOMINAL_FILAMENT_DIA,  // Nominal filament width. Change with M404.
-        filament_width_meas = DEFAULT_MEASURED_FILAMENT_DIA;    // Measured filament diameter
-  uint8_t meas_delay_cm = MEASUREMENT_DELAY_CM,                 // Distance delay setting
-          measurement_delay[MAX_MEASUREMENT_DELAY + 1];         // Ring buffer to delayed measurement. Store extruder factor after subtracting 100
-  int8_t filwidth_delay_index[2] = { 0, -1 };                   // Indexes into ring buffer
-#endif
-
 #if ENABLED(FILAMENT_RUNOUT_SENSOR)
   static bool filament_ran_out = false;
 #endif
@@ -667,13 +658,6 @@ static bool pin_is_protected(const int8_t pin) {
   #include "gcode/probe/M401_M402.h"
 #endif
 
-#if ENABLED(FILAMENT_WIDTH_SENSOR)
-  #include "gcode/sensor/M404.h"
-  #include "gcode/sensor/M405.h"
-  #include "gcode/sensor/M406.h"
-  #include "gcode/sensor/M407.h"
-#endif
-
 void quickstop_stepper() {
   stepper.quick_stop();
   stepper.synchronize();
diff --git a/Marlin/src/Marlin.h b/Marlin/src/Marlin.h
index 9e69068cfd7af4ff7d932bd388f2e5a83c8b963a..7695f03e5b31e17a5f7d6be61b2869d6a23fe5d6 100644
--- a/Marlin/src/Marlin.h
+++ b/Marlin/src/Marlin.h
@@ -211,15 +211,6 @@ extern volatile bool wait_for_heatup;
   extern uint8_t baricuda_valve_pressure, baricuda_e_to_p_pressure;
 #endif
 
-#if ENABLED(FILAMENT_WIDTH_SENSOR)
-  extern bool filament_sensor;         // Flag that filament sensor readings should control extrusion
-  extern float filament_width_nominal, // Theoretical filament diameter i.e., 3.00 or 1.75
-               filament_width_meas;    // Measured filament diameter
-  extern uint8_t meas_delay_cm,        // Delay distance
-                 measurement_delay[];  // Ring buffer to delay measurement
-  extern int8_t filwidth_delay_index[2]; // Ring buffer indexes. Used by planner, temperature, and main code
-#endif
-
 #if ENABLED(ADVANCED_PAUSE_FEATURE)
   extern AdvancedPauseMenuResponse advanced_pause_menu_response;
 #endif
diff --git a/Marlin/src/gcode/sensor/M406.h b/Marlin/src/feature/filwidth.cpp
similarity index 53%
rename from Marlin/src/gcode/sensor/M406.h
rename to Marlin/src/feature/filwidth.cpp
index 0074d8eb58f1eabb68268a16837c95e9fc4ab75a..e43a9ccd7d0a62845aaf6ed176679bbc61f9aae8 100644
--- a/Marlin/src/gcode/sensor/M406.h
+++ b/Marlin/src/feature/filwidth.cpp
@@ -20,10 +20,17 @@
  *
  */
 
-/**
- * M406: Turn off filament sensor for control
- */
-void gcode_M406() {
-  filament_sensor = false;
-  calculate_volumetric_multipliers();   // Restore correct 'volumetric_multiplier' value
-}
+#include "../inc/MarlinConfig.h"
+
+#if ENABLED(FILAMENT_WIDTH_SENSOR)
+
+#include "filwidth.h"
+
+bool filament_sensor = false;                                 // M405/M406 turns filament sensor control ON/OFF.
+float filament_width_nominal = DEFAULT_NOMINAL_FILAMENT_DIA,  // Nominal filament width. Change with M404.
+      filament_width_meas = DEFAULT_MEASURED_FILAMENT_DIA;    // Measured filament diameter
+uint8_t meas_delay_cm = MEASUREMENT_DELAY_CM,                 // Distance delay setting
+        measurement_delay[MAX_MEASUREMENT_DELAY + 1];         // Ring buffer to delayed measurement. Store extruder factor after subtracting 100
+int8_t filwidth_delay_index[2] = { 0, -1 };                   // Indexes into ring buffer
+
+#endif // FILAMENT_WIDTH_SENSOR
diff --git a/Marlin/src/gcode/sensor/M404.h b/Marlin/src/feature/filwidth.h
similarity index 53%
rename from Marlin/src/gcode/sensor/M404.h
rename to Marlin/src/feature/filwidth.h
index f94cdc2dccdfd7c433da976777907d13388456fb..43680593909d0815cf10a722febe8a9cf1806b8e 100644
--- a/Marlin/src/gcode/sensor/M404.h
+++ b/Marlin/src/feature/filwidth.h
@@ -20,15 +20,16 @@
  *
  */
 
-/**
- * M404: Display or set (in current units) the nominal filament width (3mm, 1.75mm ) W<3.0>
- */
-void gcode_M404() {
-  if (parser.seen('W')) {
-    filament_width_nominal = parser.value_linear_units();
-  }
-  else {
-    SERIAL_PROTOCOLPGM("Filament dia (nominal mm):");
-    SERIAL_PROTOCOLLN(filament_width_nominal);
-  }
-}
+#ifndef __FILWIDTH_H__
+#define __FILWIDTH_H__
+
+#include "../inc/MarlinConfig.h"
+
+extern bool filament_sensor;                                  // M405/M406 turns filament sensor control ON/OFF.
+extern float filament_width_nominal,                          // Nominal filament width. Change with M404.
+             filament_width_meas;                             // Measured filament diameter
+extern uint8_t meas_delay_cm,                                 // Distance delay setting
+               measurement_delay[MAX_MEASUREMENT_DELAY + 1];  // Ring buffer to delayed measurement. Store extruder factor after subtracting 100
+extern int8_t filwidth_delay_index[2];                        // Indexes into ring buffer
+
+#endif // __FILWIDTH_H__
diff --git a/Marlin/src/gcode/sensor/M405.h b/Marlin/src/gcode/feature/filwidth/M404-M407.cpp
similarity index 64%
rename from Marlin/src/gcode/sensor/M405.h
rename to Marlin/src/gcode/feature/filwidth/M404-M407.cpp
index bd1ed80880d5e3dba601dbb17f5107a3eb8d8f01..42ac9b622ae00b82f1f6c2c952254d43c4f15f16 100644
--- a/Marlin/src/gcode/sensor/M405.h
+++ b/Marlin/src/gcode/feature/filwidth/M404-M407.cpp
@@ -20,10 +20,33 @@
  *
  */
 
+#include "../../../inc/MarlinConfig.h"
+
+#if ENABLED(FILAMENT_WIDTH_SENSOR)
+
+#include "../../../feature/filwidth.h"
+#include "../../../module/planner.h"
+#include "../../../module/temperature.h"
+#include "../../../Marlin.h"
+#include "../../gcode.h"
+
+/**
+ * M404: Display or set (in current units) the nominal filament width (3mm, 1.75mm ) W<3.0>
+ */
+void GcodeSuite::M404() {
+  if (parser.seen('W')) {
+    filament_width_nominal = parser.value_linear_units();
+  }
+  else {
+    SERIAL_PROTOCOLPGM("Filament dia (nominal mm):");
+    SERIAL_PROTOCOLLN(filament_width_nominal);
+  }
+}
+
 /**
  * M405: Turn on filament sensor for control
  */
-void gcode_M405() {
+void GcodeSuite::M405() {
   // This is technically a linear measurement, but since it's quantized to centimeters and is a different
   // unit than everything else, it uses parser.value_byte() instead of parser.value_linear_units().
   if (parser.seen('D')) {
@@ -47,3 +70,21 @@ void gcode_M405() {
   //SERIAL_PROTOCOLPGM("Extrusion ratio(%):");
   //SERIAL_PROTOCOL(planner.flow_percentage[active_extruder]);
 }
+
+/**
+ * M406: Turn off filament sensor for control
+ */
+void GcodeSuite::M406() {
+  filament_sensor = false;
+  calculate_volumetric_multipliers();   // Restore correct 'volumetric_multiplier' value
+}
+
+/**
+ * M407: Get measured filament diameter on serial output
+ */
+void GcodeSuite::M407() {
+  SERIAL_PROTOCOLPGM("Filament dia (measured mm):");
+  SERIAL_PROTOCOLLN(filament_width_meas);
+}
+
+#endif // FILAMENT_WIDTH_SENSOR
diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp
index 3d92736aeedbab7a734b2c17e2816ba3469e0c6a..530a689468b607c59b657534da9ebd665420f1ee 100644
--- a/Marlin/src/gcode/gcode.cpp
+++ b/Marlin/src/gcode/gcode.cpp
@@ -102,11 +102,6 @@ void GcodeSuite::get_destination_from_command() {
 //
 // Placeholders for non-migrated codes
 //
-extern void gcode_G0_G1(
-  #if IS_SCARA
-    bool fast_move=false
-  #endif
-);
 extern void gcode_G2_G3(bool clockwise);
 extern void gcode_G4();
 extern void gcode_G5();
@@ -216,10 +211,6 @@ extern void gcode_M381();
 extern void gcode_M400();
 extern void gcode_M401();
 extern void gcode_M402();
-extern void gcode_M404();
-extern void gcode_M405();
-extern void gcode_M406();
-extern void gcode_M407();
 extern void gcode_M410();
 extern void gcode_M428();
 extern void gcode_M500();
@@ -871,16 +862,16 @@ void GcodeSuite::process_next_command() {
 
       #if ENABLED(FILAMENT_WIDTH_SENSOR)
         case 404:  // M404: Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width
-          gcode_M404();
+          M404();
           break;
         case 405:  // M405: Turn on filament sensor for control
-          gcode_M405();
+          M405();
           break;
         case 406:  // M406: Turn off filament sensor for control
-          gcode_M406();
+          M406();
           break;
         case 407:   // M407: Display measured filament diameter
-          gcode_M407();
+          M407();
           break;
       #endif // FILAMENT_WIDTH_SENSOR
 
diff --git a/Marlin/src/gcode/sensor/M407.h b/Marlin/src/gcode/sensor/M407.h
deleted file mode 100644
index a68bc89632dc867b0f6752d141309c81ef11052a..0000000000000000000000000000000000000000
--- a/Marlin/src/gcode/sensor/M407.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/**
- * M407: Get measured filament diameter on serial output
- */
-void gcode_M407() {
-  SERIAL_PROTOCOLPGM("Filament dia (measured mm):");
-  SERIAL_PROTOCOLLN(filament_width_meas);
-}
diff --git a/Marlin/src/lcd/ultralcd.cpp b/Marlin/src/lcd/ultralcd.cpp
index 49ce24d5b8f982b97b59e7257f2a382b7107ba6f..e4bbf0044856fd87421b71bd8bebb2bced3fb8d0 100644
--- a/Marlin/src/lcd/ultralcd.cpp
+++ b/Marlin/src/lcd/ultralcd.cpp
@@ -47,10 +47,6 @@
   #include "../feature/filwidth.h"
 #endif
 
-#if HAS_BED_PROBE
-  #include "../module/probe.h"
-#endif
-
 #if ENABLED(BLTOUCH)
   #include "../module/endstops.h"
 #endif
diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp
index c37fe01bb9b0516ba57048bd36318b43394fca9a..d17a321aa3087b59775610b3207b869207b33932 100644
--- a/Marlin/src/module/planner.cpp
+++ b/Marlin/src/module/planner.cpp
@@ -72,6 +72,10 @@
   #include "../feature/bedlevel/bedlevel.h"
 #endif
 
+#if ENABLED(FILAMENT_WIDTH_SENSOR)
+  #include "../feature/filwidth.h"
+#endif
+
 Planner planner;
 
   // public:
diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp
index 8944e581bfdaa3edd11a617c8ef5152dd2c6e50b..57eb529f2a28d74208754f5b8b1a21bf54d2d284 100644
--- a/Marlin/src/module/temperature.cpp
+++ b/Marlin/src/module/temperature.cpp
@@ -45,6 +45,10 @@
 
 #include "printcounter.h"
 
+#if ENABLED(FILAMENT_WIDTH_SENSOR)
+  #include "../feature/filwidth.h"
+#endif
+
 #ifdef K1 // Defined in Configuration.h in the PID settings
   #define K2 (1.0-K1)
 #endif