Moved ActiveVessel check from UpdateModules to FixedUpdate
Moved ActiveVessel check from UpdateModules to FixedUpdate

--- a/KerbalEngineer/Flight/FlightAppLauncher.cs
+++ b/KerbalEngineer/Flight/FlightAppLauncher.cs
@@ -179,6 +179,9 @@
 
         protected virtual void Update()
         {
+            if (Button == null)
+                return;
+
             if (FlightEngineerCore.IsDisplayable && Button.IsEnabled == false)
             {
                 Enable();

--- a/KerbalEngineer/Flight/FlightEngineerCore.cs
+++ b/KerbalEngineer/Flight/FlightEngineerCore.cs
@@ -290,6 +290,9 @@
         /// </summary>
         private void FixedUpdate()
         {
+            if (FlightGlobals.ActiveVessel == null)
+                return;
+
             try
             {
                 SectionLibrary.FixedUpdate();
@@ -351,6 +354,9 @@
         /// </summary>
         private void Update()
         {
+            if (FlightGlobals.ActiveVessel == null)
+                return;
+
             try
             {
                 SectionLibrary.Update();

--- a/KerbalEngineer/VesselSimulator/AttachNodeSim.cs
+++ b/KerbalEngineer/VesselSimulator/AttachNodeSim.cs
@@ -51,7 +51,10 @@
             return nodeSim;
         }
 
-        static private void Reset(AttachNodeSim attachNodeSim) { }
+        static private void Reset(AttachNodeSim attachNodeSim)
+        {
+            attachNodeSim.attachedPartSim = null;
+        }
 
 
         public void Release()

--- a/KerbalEngineer/VesselSimulator/EngineSim.cs
+++ b/KerbalEngineer/VesselSimulator/EngineSim.cs
@@ -54,6 +54,7 @@
         {
             engineSim.resourceConsumptions.Reset();
             engineSim.resourceFlowModes.Reset();
+            engineSim.partSim = null;
             engineSim.actualThrust = 0;
             engineSim.isActive = false;
             engineSim.isp = 0;

--- a/KerbalEngineer/VesselSimulator/PartSim.cs
+++ b/KerbalEngineer/VesselSimulator/PartSim.cs
@@ -86,9 +86,11 @@
             }
             partSim.attachNodes.Clear();
             partSim.fuelTargets.Clear();
+            partSim.surfaceMountFuelTargets.Clear();
             partSim.resourceDrains.Reset();
             partSim.resourceFlowStates.Reset();
             partSim.resources.Reset();
+            partSim.parent = null;
             partSim.baseCost = 0d;
             partSim.baseMass = 0d;
             partSim.baseMassForCoM = 0d;
@@ -626,6 +628,17 @@
                     this.fuelTargets[i] = null;
                 }
             }
+
+            // Loop through the surface attached fuel targets (surface attached parts for new flow modes)
+            for (int i = 0; i < this.surfaceMountFuelTargets.Count; i++)
+            {
+                PartSim fuelTargetSim = this.surfaceMountFuelTargets[i];
+                // If the part is in the set then "remove" it by clearing the PartSim reference
+                if (fuelTargetSim != null && partSims.Contains(fuelTargetSim))
+                {
+                    this.surfaceMountFuelTargets[i] = null;
+                }
+            }
         }
 
         public void SetupAttachNodes(Dictionary<Part, PartSim> partSimLookup, LogMsg log)