Simplified null or empty check for readability.
Simplified null or empty check for readability.

--- a/Documents/CHANGES.txt
+++ b/Documents/CHANGES.txt
@@ -1,4 +1,5 @@
-1.0.19.0
+1.0.19.1, 09-11-15
+    Added: Key binding editor accessible under 'Settings' on the Build Engineer.
     Added: Added current vessel name readout. (antplant)
     Added: 'Relative Radial Velocity' and 'Time To Rendezvous' readouts. (itwtx)
     Added: Readout help strings. (harryyoung)

--- a/KerbalEngineer/Editor/BuildAdvanced.cs
+++ b/KerbalEngineer/Editor/BuildAdvanced.cs
@@ -547,6 +547,14 @@
             GUILayout.EndHorizontal();
 
             GUILayout.BeginHorizontal();
+            GUILayout.Label("Key Bindings:", settingStyle);
+            if (GUILayout.Button("EDIT KEY BINDINGS", buttonStyle, GUILayout.Width(200.0f * GuiDisplaySize.Offset)))
+            {
+                KeyBinder.Show();
+            }
+            GUILayout.EndHorizontal();
+
+            GUILayout.BeginHorizontal();
             GUILayout.Label("GUI Size: " + GuiDisplaySize.Increment, settingStyle);
             if (GUILayout.Button("<", buttonStyle, GUILayout.Width(100.0f * GuiDisplaySize.Offset)))
             {
@@ -561,17 +569,6 @@
             GUILayout.Label("Minimum delay between simulations: " + SimManager.minSimTime.TotalMilliseconds + "ms", settingStyle);
             GUI.skin = HighLogic.Skin;
             SimManager.minSimTime = TimeSpan.FromMilliseconds(GUILayout.HorizontalSlider((float)SimManager.minSimTime.TotalMilliseconds, 0, 2000.0f));
-
-            GUILayout.BeginHorizontal();
-            if (GUILayout.Button("Editor Show/Hide Key: " + KeyBinder.EditorShowHide, buttonStyle, GUILayout.Width(200.0f * GuiDisplaySize.Offset)))
-            {
-                KeyBindPopup.Show("Flight Show/Hide", KeyBinder.EditorShowHide, keyCode => KeyBinder.EditorShowHide = keyCode);
-            }
-            if (GUILayout.Button("Flight Show/Hide Key: " + KeyBinder.FlightShowHide, buttonStyle, GUILayout.Width(200.0f * GuiDisplaySize.Offset)))
-            {
-                KeyBindPopup.Show("Flight Show/Hide", KeyBinder.FlightShowHide, keyCode => KeyBinder.FlightShowHide = keyCode);
-            }
-            GUILayout.EndHorizontal();
 
             GUI.skin = null;
         }

--- a/KerbalEngineer/EngineerGlobals.cs
+++ b/KerbalEngineer/EngineerGlobals.cs
@@ -25,7 +25,7 @@
         /// <summary>
         ///     Current version of the Kerbal Engineer assembly.
         /// </summary>
-        public const string ASSEMBLY_VERSION = "1.0.18.1";
+        public const string ASSEMBLY_VERSION = "1.0.19.2";
 
         private static string assemblyFile;
         private static string assemblyName;

--- a/KerbalEngineer/KerbalEngineer.csproj
+++ b/KerbalEngineer/KerbalEngineer.csproj
@@ -238,7 +238,7 @@
   </ItemGroup>
   <ItemGroup>
     <Reference Include="Assembly-CSharp">
-      <HintPath>..\Game\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
+      <HintPath>..\..\Game\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
       <Private>False</Private>
     </Reference>
     <Reference Include="System">
@@ -250,7 +250,7 @@
       <Private>False</Private>
     </Reference>
     <Reference Include="UnityEngine">
-      <HintPath>..\Game\KSP_Data\Managed\UnityEngine.dll</HintPath>
+      <HintPath>..\..\Game\KSP_Data\Managed\UnityEngine.dll</HintPath>
       <Private>False</Private>
     </Reference>
   </ItemGroup>
@@ -269,7 +269,7 @@
         $(PostBuildEventDependsOn);
         PostBuildMacros;
       </PostBuildEventDependsOn>
-    <PostBuildEvent>xcopy "$(SolutionDir)Output\*" "$(SolutionDir)Game\GameData\*" /E /Y
+    <PostBuildEvent>xcopy "$(SolutionDir)Output\*" "$(SolutionDir)..\Game\GameData\*" /E /Y
 del "$(SolutionDir)Release\*" /Q
 xcopy "$(SolutionDir)Documents\*" "$(SolutionDir)Release\Documents\*" /E /Y
 7z.exe a -tzip -mx3 "$(SolutionDir)Release\$(ProjectName)-@(VersionNumber).zip" "$(SolutionDir)Output\*"

--- a/KerbalEngineer/KeyBinding/KeyBindPopup.cs
+++ b/KerbalEngineer/KeyBinding/KeyBindPopup.cs
@@ -20,48 +20,78 @@
 namespace KerbalEngineer.KeyBinding
 {
     using System;
+    using Extensions;
     using UnityEngine;
 
     public class KeyBindPopup : MonoBehaviour
     {
+        private const string LOCK_ID = "KER_KeyBindPopup";
+        private static Rect position = new Rect(Screen.width, Screen.height, 250.0f, 0.0f);
+        private static bool hasCentred;
+        private static KeyBindPopup instance;
         private readonly Array availableBindings = Enum.GetValues(typeof(KeyCode));
-        private bool isCentred;
-        private Rect position = new Rect(0.0f, 0.0f, 250.0f, 0.0f);
+
+        /// <summary>
+        ///     Gets the delegate to be invoked when accepted button is clicked.
+        /// </summary>
+        public Action<KeyCode> AcceptClicked { get; private set; }
+
+        /// <summary>
+        ///     Gets the name of the binding to change.
+        /// </summary>
+        public string Name { get; private set; }
+
+        /// <summary>
+        ///     Gets the selected binding.
+        /// </summary>
+        public KeyCode Binding { get; private set; }
 
         /// <summary>
         ///     Gets whether a key bind popup is already open.
         /// </summary>
-        public static bool IsOpen { get; private set; }
-
-        /// <summary>
-        ///     Gets the delegate to be invoked when accepted button is clicked.
-        /// </summary>
-        public Action<KeyCode> AcceptClicked { get; private set; }
-
-        /// <summary>
-        ///     Gets the name of the binding to change.
-        /// </summary>
-        public string Name { get; private set; }
-
-        /// <summary>
-        ///     Gets the selected binding.
-        /// </summary>
-        public KeyCode Binding { get; private set; }
+        public static bool IsOpen
+        {
+            get
+            {
+                return (instance != null);
+            }
+        }
+
+        /// <summary>
+        ///     Gets and sets the input lock state.
+        /// </summary>
+        public bool InputLock
+        {
+            get
+            {
+                return InputLockManager.GetControlLock(LOCK_ID) != ControlTypes.None;
+            }
+            set
+            {
+                if (value)
+                {
+                    InputLockManager.SetControlLock(ControlTypes.All, LOCK_ID);
+                }
+                else
+                {
+                    InputLockManager.SetControlLock(ControlTypes.None, LOCK_ID);
+                }
+            }
+        }
 
         /// <summary>
         ///     Shows a key bind popup allowing the user to select a key for binding.
         /// </summary>
         public static void Show(string name, KeyCode currentBinding, Action<KeyCode> acceptClicked)
         {
-            if (IsOpen)
-            {
-                return;
-            }
-
-            KeyBindPopup keyBindPopup = new GameObject("SelectKeyBind").AddComponent<KeyBindPopup>();
-            keyBindPopup.Name = name;
-            keyBindPopup.Binding = currentBinding;
-            keyBindPopup.AcceptClicked = acceptClicked;
+            if (instance == null)
+            {
+                instance = new GameObject("SelectKeyBind").AddComponent<KeyBindPopup>();
+            }
+
+            instance.Name = name;
+            instance.Binding = currentBinding;
+            instance.AcceptClicked = acceptClicked;
         }
 
         /// <summary>
@@ -89,14 +119,14 @@
         /// </summary>
         protected virtual void Awake()
         {
-            if (IsOpen)
+            if (instance == null)
+            {
+                instance = this;
+            }
+            else if (instance != this)
             {
                 OnCancel();
             }
-            else
-            {
-                IsOpen = true;
-            }
         }
 
         /// <summary>
@@ -104,7 +134,7 @@
         /// </summary>
         protected virtual void OnDestroy()
         {
-            IsOpen = false;
+            InputLock = false;
         }
 
         /// <summary>
@@ -112,7 +142,7 @@
         /// </summary>
         protected virtual void OnGUI()
         {
-            position = GUILayout.Window(GetInstanceID(), position, RenderWindow, "Select Key Bind", HighLogic.Skin.window);
+            position = GUILayout.Window(GetInstanceID(), position, RenderWindow, "Select Key Bind", HighLogic.Skin.window).ClampToScreen();
             CentreWindow();
         }
 
@@ -123,16 +153,17 @@
         {
             CentreWindow();
             UpdateBinding();
+            UpdateInputLock();
         }
 
         /// <summary>
         ///     Centres the window on the screen.
         /// </summary>
-        private void CentreWindow()
-        {
-            if (isCentred == false && position.width > 0.0f && position.height > 0.0f)
-            {
-                isCentred = true;
+        private static void CentreWindow()
+        {
+            if (hasCentred == false && position.width > 0.0f && position.height > 0.0f)
+            {
+                hasCentred = true;
                 position.center = new Vector2(Screen.width * 0.5f, Screen.height * 0.5f);
             }
         }
@@ -142,6 +173,8 @@
         /// </summary>
         private void RenderWindow(int id)
         {
+            GUILayout.Label("Press the desired key to change it.");
+
             // Binding labels.
             GUILayout.BeginVertical(HighLogic.Skin.textArea);
             GUILayout.Label("Key Bind: " + Name);
@@ -181,8 +214,29 @@
 
                 if (Input.GetKeyDown(keyCode))
                 {
-                    Binding = keyCode;
-                }
+                    if (Input.GetKeyDown(keyCode))
+                    {
+                        Binding = keyCode;
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        ///     Updates the input lock.
+        /// </summary>
+        private void UpdateInputLock()
+        {
+            bool mouseOver = position.MouseIsOver();
+            bool inputLock = InputLock;
+
+            if (mouseOver && inputLock == false)
+            {
+                InputLock = true;
+            }
+            else if (mouseOver == false && inputLock)
+            {
+                InputLock = false;
             }
         }
     }

--- a/KerbalEngineer/KeyBinding/KeyBinder.cs
+++ b/KerbalEngineer/KeyBinding/KeyBinder.cs
@@ -19,19 +19,29 @@
 
 namespace KerbalEngineer.KeyBinding
 {
+    using System;
     using System.IO;
+    using Extensions;
     using Helpers;
     using UnityEngine;
 
-    public class KeyBinder
+    public class KeyBinder : MonoBehaviour
     {
+        private const string LOCK_ID = "KER_KeyBinder";
         private static readonly string filePath = Path.Combine(EngineerGlobals.SettingsPath, "KeyBinds.xml");
         private static KeyBindingsObject bindings;
+        private static Rect position = new Rect(Screen.width, Screen.height, 500.0f, 0.0f);
+        private static bool hasCentred;
 
         static KeyBinder()
         {
             Load();
         }
+
+        /// <summary>
+        ///     Gets whether the key binder window is open.
+        /// </summary>
+        public static bool IsOpen { get; private set; }
 
         /// <summary>
         ///     Gets and sets the key bindings object.
@@ -88,6 +98,28 @@
         }
 
         /// <summary>
+        ///     Gets and sets the input lock state.
+        /// </summary>
+        public bool InputLock
+        {
+            get
+            {
+                return InputLockManager.GetControlLock(LOCK_ID) != ControlTypes.None;
+            }
+            set
+            {
+                if (value)
+                {
+                    InputLockManager.SetControlLock(ControlTypes.All, LOCK_ID);
+                }
+                else
+                {
+                    InputLockManager.SetControlLock(ControlTypes.None, LOCK_ID);
+                }
+            }
+        }
+
+        /// <summary>
         ///     Loads the key bindings from disk.
         /// </summary>
         public static void Load()
@@ -101,6 +133,123 @@
         public static void Save()
         {
             XmlHelper.SaveObject(filePath, Bindings);
+        }
+
+        /// <summary>
+        ///     Shows the key binding window.
+        /// </summary>
+        public static void Show()
+        {
+            if (IsOpen)
+            {
+                return;
+            }
+
+            new GameObject("KeyBinder").AddComponent<KeyBinder>();
+        }
+
+        /// <summary>
+        ///     Called by unity when component is created.
+        /// </summary>
+        protected virtual void Awake()
+        {
+            if (IsOpen)
+            {
+                Destroy(gameObject);
+            }
+            else
+            {
+                IsOpen = true;
+                position.height = 0.0f;
+            }
+        }
+
+        /// <summary>
+        ///     Called by unity when component is destroyed.
+        /// </summary>
+        protected virtual void OnDestroy()
+        {
+            IsOpen = false;
+            InputLock = false;
+        }
+
+        /// <summary>
+        ///     Called by unity to draw the GUI.
+        /// </summary>
+        protected virtual void OnGUI()
+        {
+            position = GUILayout.Window(GetInstanceID(), position, RenderWindow, "Kerbal Engineer Redux - Key Bindings", HighLogic.Skin.window).ClampToScreen();
+            CentreWindow();
+        }
+
+        /// <summary>
+        ///     Called by unity every frame.
+        /// </summary>
+        protected virtual void Update()
+        {
+            UpdateInputLock();
+        }
+
+        /// <summary>
+        ///     Renders a key bind option.
+        /// </summary>
+        private static void RenderKeyBind(string name, KeyCode currentBinding, Action<KeyCode> acceptClicked)
+        {
+            GUILayout.BeginHorizontal();
+            GUILayout.Label(name);
+            if (GUILayout.Button(currentBinding.ToString(), HighLogic.Skin.button, GUILayout.Width(100.0f)))
+            {
+                KeyBindPopup.Show(name, currentBinding, acceptClicked);
+            }
+            GUILayout.EndHorizontal();
+        }
+
+        /// <summary>
+        ///     Centres the window on screen.
+        /// </summary>
+        private void CentreWindow()
+        {
+            if (hasCentred == false && position.width > 0.0f && position.height > 0.0f)
+            {
+                hasCentred = true;
+                position.center = new Vector2(Screen.width * 0.5f, Screen.height * 0.5f);
+            }
+        }
+
+        /// <summary>
+        ///     Renders the GUI window contents.
+        /// </summary>
+        private void RenderWindow(int id)
+        {
+            GUILayout.BeginVertical(HighLogic.Skin.textArea);
+            RenderKeyBind("Editor Show/Hide", EditorShowHide, binding => EditorShowHide = binding);
+            RenderKeyBind("Flight Show/Hide", FlightShowHide, binding => FlightShowHide = binding);
+            GUILayout.EndVertical();
+
+            if (GUILayout.Button("Close", HighLogic.Skin.button))
+            {
+                Destroy(gameObject);
+            }
+
+            GUI.DragWindow();
+        }
+
+        /// <summary>
+        ///     Updates the input lock.
+        /// </summary>
+        private void UpdateInputLock()
+        {
+            bool mouseOver = position.MouseIsOver();
+            bool inputLock = InputLock;
+
+            if (mouseOver && inputLock == false)
+            {
+                InputLock = true;
+            }
+            else if (mouseOver == false && inputLock)
+            {
+                InputLock = false;
+            }
         }
     }
 }

--- a/KerbalEngineer/KeyBinding/KeyBindingsObject.cs
+++ b/KerbalEngineer/KeyBinding/KeyBindingsObject.cs
@@ -19,6 +19,7 @@
 
 namespace KerbalEngineer.KeyBinding
 {
+    using System.Xml.Serialization;
     using UnityEngine;
 
     public class KeyBindingsObject

--- a/KerbalEngineer/VesselSimulator/EngineSim.cs
+++ b/KerbalEngineer/VesselSimulator/EngineSim.cs
@@ -327,6 +327,7 @@
                         break;
 
                     case ResourceFlowMode.ALL_VESSEL:
+                    case ResourceFlowMode.ALL_VESSEL_BALANCE:
                         for (int i = 0; i < allParts.Count; i++)
                         {
                             PartSim aPartSim = allParts[i];
@@ -338,6 +339,7 @@
                         break;
 
                     case ResourceFlowMode.STAGE_PRIORITY_FLOW:
+                    case ResourceFlowMode.STAGE_PRIORITY_FLOW_BALANCE:
 
                         foreach (HashSet<PartSim> stagePartSet in stagePartSets.Values)
                         {
@@ -386,6 +388,8 @@
                         break;
 
                     case ResourceFlowMode.STACK_PRIORITY_SEARCH:
+                    case ResourceFlowMode.STAGE_STACK_FLOW:
+                    case ResourceFlowMode.STAGE_STACK_FLOW_BALANCE:
                         visited.Clear();
 
                         if (SimManager.logOutput)

--- a/KerbalEngineer/VesselSimulator/PartSim.cs
+++ b/KerbalEngineer/VesselSimulator/PartSim.cs
@@ -519,9 +519,7 @@
                     {
                         if (attachSim.nodeType == AttachNode.NodeType.Stack)
                         {
-                            if (
-                                !(this.noCrossFeedNodeKey != null && this.noCrossFeedNodeKey.Length > 0 &&
-                                  attachSim.id.Contains(this.noCrossFeedNodeKey)))
+                            if ((string.IsNullOrEmpty(noCrossFeedNodeKey) == false && attachSim.id.Contains(noCrossFeedNodeKey)) == false)
                             {
                                 if (visited.Contains(attachSim.attachedPartSim))
                                 {
@@ -549,7 +547,7 @@
             // type was not disabled [Experiment]) and it contains fuel, it returns itself.
             // Rule 6: If the part is fuel container for searched type of fuel (i.e. it has capability to contain that type of fuel and the fuel 
             // type was not disabled) but it does not contain the requested fuel, it returns empty list. [Experiment]
-            if (resources.HasType(type) && resourceFlowStates[type] != 0)
+            if (resources.HasType(type) && resourceFlowStates[type] > 0.0)
             {
                 if (resources[type] > SimManager.RESOURCE_MIN)
                 {

 Binary files a/Output/KerbalEngineer/KerbalEngineer.dll and b/Output/KerbalEngineer/KerbalEngineer.dll differ
--- a/Output/KerbalEngineer/KerbalEngineer.version
+++ b/Output/KerbalEngineer/KerbalEngineer.version
@@ -5,14 +5,14 @@
 	{
 		"MAJOR":1,
 		"MINOR":0,
-		"PATCH":18,
-		"BUILD":0
+		"PATCH":19,
+		"BUILD":2
 	},
 	"KSP_VERSION":
 	{
 		"MAJOR":1,
 		"MINOR":0,
-		"PATCH":4
+		"PATCH":5
 	}
 }