diff --git a/Assets/Fungus/Scripts/Commands/Call.cs b/Assets/Fungus/Scripts/Commands/Call.cs
index 93246a1d..d7076715 100644
--- a/Assets/Fungus/Scripts/Commands/Call.cs
+++ b/Assets/Fungus/Scripts/Commands/Call.cs
@@ -161,6 +161,11 @@ namespace Fungus
             return new Color32(235, 191, 217, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return startLabel.stringRef == variable || base.HasReference(variable);
+        }
+
         #endregion
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/ControlAudio.cs b/Assets/Fungus/Scripts/Commands/ControlAudio.cs
index 8a5ad5fe..d4100ead 100644
--- a/Assets/Fungus/Scripts/Commands/ControlAudio.cs
+++ b/Assets/Fungus/Scripts/Commands/ControlAudio.cs
@@ -284,6 +284,11 @@ namespace Fungus
             return new Color32(242, 209, 176, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _audioSource.audioSourceRef == variable || base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/Conversation.cs b/Assets/Fungus/Scripts/Commands/Conversation.cs
index 42e1da4a..e7cdbd0c 100644
--- a/Assets/Fungus/Scripts/Commands/Conversation.cs
+++ b/Assets/Fungus/Scripts/Commands/Conversation.cs
@@ -63,6 +63,27 @@ namespace Fungus
             return new Color32(184, 210, 235, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return clearPrevious.booleanRef == variable || waitForInput.booleanRef == variable || 
+                waitForSeconds.floatRef == variable || fadeWhenDone.booleanRef == variable ||
+                base.HasReference(variable);
+        }
+
         #endregion
+
+
+        #region Editor caches
+#if UNITY_EDITOR
+        protected override void RefreshVariableCache()
+        {
+            base.RefreshVariableCache();
+
+            var f = GetFlowchart();
+
+            f.DetermineSubstituteVariables(conversationText, referencedVariables);
+        }
+#endif
+        #endregion Editor caches
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/DebugLog.cs b/Assets/Fungus/Scripts/Commands/DebugLog.cs
index fce1c374..6c39772b 100644
--- a/Assets/Fungus/Scripts/Commands/DebugLog.cs
+++ b/Assets/Fungus/Scripts/Commands/DebugLog.cs
@@ -66,6 +66,24 @@ namespace Fungus
             return new Color32(235, 191, 217, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return logMessage.stringRef == variable || base.HasReference(variable);
+        }
+
         #endregion
+
+        #region Editor caches
+#if UNITY_EDITOR
+        protected override void RefreshVariableCache()
+        {
+            base.RefreshVariableCache();
+
+            var f = GetFlowchart();
+
+            f.DetermineSubstituteVariables(logMessage.Value, referencedVariables);
+        }
+#endif
+        #endregion Editor caches
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/DeleteSaveKey.cs b/Assets/Fungus/Scripts/Commands/DeleteSaveKey.cs
index 6b7559ac..e9a6e6b5 100644
--- a/Assets/Fungus/Scripts/Commands/DeleteSaveKey.cs
+++ b/Assets/Fungus/Scripts/Commands/DeleteSaveKey.cs
@@ -53,5 +53,18 @@ namespace Fungus
         }
 
         #endregion
-    }    
+
+        #region Editor caches
+#if UNITY_EDITOR
+        protected override void RefreshVariableCache()
+        {
+            base.RefreshVariableCache();
+
+            var f = GetFlowchart();
+
+            f.DetermineSubstituteVariables(key, referencedVariables);
+        }
+#endif
+        #endregion Editor caches
+    }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/ExecuteLua.cs b/Assets/Fungus/Scripts/Commands/ExecuteLua.cs
index 501c45c4..cf538c75 100644
--- a/Assets/Fungus/Scripts/Commands/ExecuteLua.cs
+++ b/Assets/Fungus/Scripts/Commands/ExecuteLua.cs
@@ -203,6 +203,11 @@ namespace Fungus
             return new Color32(235, 191, 217, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return returnVariable == variable || base.HasReference(variable);
+        }
+
         #endregion
     }
 }
diff --git a/Assets/Fungus/Scripts/Commands/FadeSprite.cs b/Assets/Fungus/Scripts/Commands/FadeSprite.cs
index 0d41b643..af68b7b5 100644
--- a/Assets/Fungus/Scripts/Commands/FadeSprite.cs
+++ b/Assets/Fungus/Scripts/Commands/FadeSprite.cs
@@ -66,6 +66,12 @@ namespace Fungus
             return new Color32(221, 184, 169, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _duration.floatRef == variable || _targetColor.colorRef == variable ||
+                base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/FadeUI.cs b/Assets/Fungus/Scripts/Commands/FadeUI.cs
index f3cf5d26..0c47f735 100644
--- a/Assets/Fungus/Scripts/Commands/FadeUI.cs
+++ b/Assets/Fungus/Scripts/Commands/FadeUI.cs
@@ -1,7 +1,7 @@
 // This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
 // It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
 
-using UnityEngine;
+using UnityEngine;
 using UnityEngine.UI;
 
 namespace Fungus
@@ -221,7 +221,7 @@ namespace Fungus
             return "";
         }
 
-#region Public members
+        #region Public members
 
         public override bool IsPropertyVisible(string propertyName)
         {
@@ -240,6 +240,12 @@ namespace Fungus
             return true;
         }
 
-#endregion
+        public override bool HasReference(Variable variable)
+        {
+            return targetColor.colorRef == variable || targetAlpha.floatRef == variable ||
+                base.HasReference(variable);
+        }
+
+        #endregion
     }
 }
diff --git a/Assets/Fungus/Scripts/Commands/FromString.cs b/Assets/Fungus/Scripts/Commands/FromString.cs
new file mode 100644
index 00000000..5caff060
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/FromString.cs
@@ -0,0 +1,82 @@
+// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+    /// <summary>
+    /// Attempts to parse a string into a given fungus variable type, such as integer or float
+    /// </summary>
+    [CommandInfo("Variable",
+                 "From String",
+                 "Attempts to parse a string into a given fungus variable type, such as integer or float")]
+    [AddComponentMenu("")]
+    public class FromString : Command
+    {
+        [Tooltip("Source of string data to parse into another variables value")]
+        [VariableProperty(typeof(StringVariable))]
+        [SerializeField] protected StringVariable sourceString;
+
+        [Tooltip("The variable type to be parsed and value stored within")]
+        [VariableProperty(typeof(IntegerVariable), typeof(FloatVariable))]
+        [SerializeField] protected Variable outValue;
+
+        public override void OnEnter()
+        {
+            if (sourceString != null && outValue != null)
+            {
+                double asDouble = 0;
+                try
+                {
+                    asDouble = System.Convert.ToDouble(sourceString.Value, System.Globalization.CultureInfo.CurrentCulture);
+                }
+                catch (System.Exception)
+                {
+                    Debug.LogWarning("Failed to parse as number: " + sourceString.Value);
+                }
+
+                IntegerVariable intOutVar = outValue as IntegerVariable;
+                if (intOutVar != null)
+                {
+                    intOutVar.Value = (int)asDouble;
+                }
+                else
+                {
+                    FloatVariable floatOutVar = outValue as FloatVariable;
+                    if (floatOutVar != null)
+                    {
+                        floatOutVar.Value = (float)asDouble;
+                    }
+                }
+            }
+
+            Continue();
+        }
+
+        public override string GetSummary()
+        {
+            if (sourceString == null)
+            {
+                return "Error: No source string selected";
+            }
+
+            if (outValue == null)
+            {
+                return "Error: No type and storage variable selected";
+            }
+
+            return outValue.Key + ".Parse " + sourceString.Key;
+        }
+
+        public override bool HasReference(Variable variable)
+        {
+            return (variable == sourceString) || (variable == outValue);
+        }
+
+        public override Color GetButtonColor()
+        {
+            return new Color32(253, 253, 150, 255);
+        }
+    }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/FromString.cs.meta b/Assets/Fungus/Scripts/Commands/FromString.cs.meta
new file mode 100644
index 00000000..a565d246
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/FromString.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 51296c2a224eea64daa8c7b9c5c644fa
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 
diff --git a/Assets/Fungus/Scripts/Commands/GetText.cs b/Assets/Fungus/Scripts/Commands/GetText.cs
index 4b0f72c6..f6c01b59 100644
--- a/Assets/Fungus/Scripts/Commands/GetText.cs
+++ b/Assets/Fungus/Scripts/Commands/GetText.cs
@@ -64,6 +64,12 @@ namespace Fungus
             return new Color32(235, 191, 217, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return stringVariable == variable || 
+                base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/GetToggleState.cs b/Assets/Fungus/Scripts/Commands/GetToggleState.cs
index 5dfe9972..17ad1242 100644
--- a/Assets/Fungus/Scripts/Commands/GetToggleState.cs
+++ b/Assets/Fungus/Scripts/Commands/GetToggleState.cs
@@ -54,6 +54,12 @@ namespace Fungus
             return toggle.name;
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return toggleState == variable || 
+                base.HasReference(variable);
+        }
+
         #endregion
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/InvokeEvent.cs b/Assets/Fungus/Scripts/Commands/InvokeEvent.cs
index 55c3e402..6cdc5bee 100644
--- a/Assets/Fungus/Scripts/Commands/InvokeEvent.cs
+++ b/Assets/Fungus/Scripts/Commands/InvokeEvent.cs
@@ -153,6 +153,13 @@ namespace Fungus
             return new Color32(235, 191, 217, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return booleanParameter.booleanRef == variable || integerParameter.integerRef == variable ||
+                floatParameter.floatRef == variable || stringParameter.stringRef == variable ||
+                base.HasReference(variable);
+        }
+
         #endregion
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Jump.cs b/Assets/Fungus/Scripts/Commands/Jump.cs
index ebaa4b4d..340841ce 100644
--- a/Assets/Fungus/Scripts/Commands/Jump.cs
+++ b/Assets/Fungus/Scripts/Commands/Jump.cs
@@ -61,6 +61,12 @@ namespace Fungus
             return new Color32(253, 253, 150, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _targetLabel.stringRef == variable ||
+                base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/LeanTween/BaseLeanTweenCommand.cs b/Assets/Fungus/Scripts/Commands/LeanTween/BaseLeanTweenCommand.cs
index e617d284..9607eb0f 100644
--- a/Assets/Fungus/Scripts/Commands/LeanTween/BaseLeanTweenCommand.cs
+++ b/Assets/Fungus/Scripts/Commands/LeanTween/BaseLeanTweenCommand.cs
@@ -110,6 +110,11 @@ namespace Fungus
             return new Color32(233, 163, 180, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return variable == _targetObject.gameObjectRef || variable == _duration.floatRef;
+        }
+
         #endregion
 
     }
diff --git a/Assets/Fungus/Scripts/Commands/LeanTween/MoveLean.cs b/Assets/Fungus/Scripts/Commands/LeanTween/MoveLean.cs
index 319bb21a..1ab79b07 100644
--- a/Assets/Fungus/Scripts/Commands/LeanTween/MoveLean.cs
+++ b/Assets/Fungus/Scripts/Commands/LeanTween/MoveLean.cs
@@ -50,6 +50,10 @@ namespace Fungus
             else
                 return LeanTween.move(_targetObject.Value, loc, _duration);
         }
-        
+
+        public override bool HasReference(Variable variable)
+        {
+            return _toTransform.transformRef == variable || _toPosition.vector3Ref == variable || base.HasReference(variable);
+        }
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/LeanTween/RotateLean.cs b/Assets/Fungus/Scripts/Commands/LeanTween/RotateLean.cs
index eaa26761..ed8c7975 100644
--- a/Assets/Fungus/Scripts/Commands/LeanTween/RotateLean.cs
+++ b/Assets/Fungus/Scripts/Commands/LeanTween/RotateLean.cs
@@ -70,5 +70,10 @@ namespace Fungus
             else
                 return LeanTween.rotate(_targetObject.Value, rot, _duration);
         }
+
+        public override bool HasReference(Variable variable)
+        {
+            return variable == _toTransform.transformRef || _toRotation.vector3Ref == variable || base.HasReference(variable);
+        }
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/LeanTween/ScaleLean.cs b/Assets/Fungus/Scripts/Commands/LeanTween/ScaleLean.cs
index cc26391f..603869e7 100644
--- a/Assets/Fungus/Scripts/Commands/LeanTween/ScaleLean.cs
+++ b/Assets/Fungus/Scripts/Commands/LeanTween/ScaleLean.cs
@@ -42,5 +42,10 @@ namespace Fungus
 
             return LeanTween.scale(_targetObject.Value, sc, _duration);
         }
+        
+        public override bool HasReference(Variable variable)
+        {
+            return variable == _toTransform.transformRef || _toScale.vector3Ref == variable || base.HasReference(variable);
+        }
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/LeanTween/StopTweensLean.cs b/Assets/Fungus/Scripts/Commands/LeanTween/StopTweensLean.cs
index 19bf64d7..24957c7d 100644
--- a/Assets/Fungus/Scripts/Commands/LeanTween/StopTweensLean.cs
+++ b/Assets/Fungus/Scripts/Commands/LeanTween/StopTweensLean.cs
@@ -43,5 +43,10 @@ namespace Fungus
         {
             return new Color32(233, 163, 180, 255);
         }
+
+        public override bool HasReference(Variable variable)
+        {
+            return _targetObject.gameObjectRef == variable;
+        }
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/LoadScene.cs b/Assets/Fungus/Scripts/Commands/LoadScene.cs
index 36208348..e99660b5 100644
--- a/Assets/Fungus/Scripts/Commands/LoadScene.cs
+++ b/Assets/Fungus/Scripts/Commands/LoadScene.cs
@@ -50,6 +50,12 @@ namespace Fungus
             return new Color32(235, 191, 217, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _sceneName.stringRef == variable ||
+                base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/LoadVariable.cs b/Assets/Fungus/Scripts/Commands/LoadVariable.cs
index ecea1bab..8e4f45ea 100644
--- a/Assets/Fungus/Scripts/Commands/LoadVariable.cs
+++ b/Assets/Fungus/Scripts/Commands/LoadVariable.cs
@@ -99,6 +99,24 @@ namespace Fungus
             return new Color32(235, 191, 217, 255);
         }
 
+        public override bool HasReference(Variable in_variable)
+        {
+            return this.variable == in_variable ||
+                base.HasReference(in_variable);
+        }
+
         #endregion
-    }    
+        #region Editor caches
+#if UNITY_EDITOR
+        protected override void RefreshVariableCache()
+        {
+            base.RefreshVariableCache();
+
+            var f = GetFlowchart();
+
+            f.DetermineSubstituteVariables(key, referencedVariables);
+        }
+#endif
+        #endregion Editor caches
+    }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/LookFrom.cs b/Assets/Fungus/Scripts/Commands/LookFrom.cs
index d3af3c15..875f7d35 100644
--- a/Assets/Fungus/Scripts/Commands/LookFrom.cs
+++ b/Assets/Fungus/Scripts/Commands/LookFrom.cs
@@ -61,6 +61,12 @@ namespace Fungus
             iTween.LookFrom(_targetObject.Value, tweenParams);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _fromTransform.transformRef == variable || _fromPosition.vector3Ref == variable ||
+                base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/LookTo.cs b/Assets/Fungus/Scripts/Commands/LookTo.cs
index c785bcce..f5a7ca59 100644
--- a/Assets/Fungus/Scripts/Commands/LookTo.cs
+++ b/Assets/Fungus/Scripts/Commands/LookTo.cs
@@ -61,6 +61,12 @@ namespace Fungus
             iTween.LookTo(_targetObject.Value, tweenParams);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _toTransform.transformRef == variable || _toPosition.vector3Ref == variable ||
+                base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/Math/Abs.cs b/Assets/Fungus/Scripts/Commands/Math/Abs.cs
index 8b9bc27e..0859907b 100644
--- a/Assets/Fungus/Scripts/Commands/Math/Abs.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/Abs.cs
@@ -17,10 +17,5 @@ namespace Fungus
 
             Continue();
         }
-
-        public override string GetSummary()
-        {
-            return "Abs";
-        }
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Math/BaseUnaryMathCommand.cs b/Assets/Fungus/Scripts/Commands/Math/BaseUnaryMathCommand.cs
index 253d834e..4a59709b 100644
--- a/Assets/Fungus/Scripts/Commands/Math/BaseUnaryMathCommand.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/BaseUnaryMathCommand.cs
@@ -21,5 +21,15 @@ namespace Fungus
             return new Color32(235, 191, 217, 255);
         }
 
+        public override string GetSummary()
+        {
+            return "in: " + (inValue.floatRef != null ? inValue.floatRef.Key : inValue.Value.ToString()) + 
+                   ", out: " + (outValue.floatRef != null ? outValue.floatRef.Key : outValue.Value.ToString());
+        }
+
+        public override bool HasReference(Variable variable)
+        {
+            return variable == inValue.floatRef || variable == outValue.floatRef;
+        }
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Math/Clamp.cs b/Assets/Fungus/Scripts/Commands/Math/Clamp.cs
index 75ce2934..181e3bf5 100644
--- a/Assets/Fungus/Scripts/Commands/Math/Clamp.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/Clamp.cs
@@ -55,7 +55,16 @@ namespace Fungus
 
         public override string GetSummary()
         {
-            return Mode.Clamp.ToString() + (mode != Mode.Clamp ? " & " + mode.ToString() : "");
+            if (outValue.floatRef == null)
+                return "Error: no output value selected";
+
+            return outValue.floatRef.Key + " = " + Mode.Clamp.ToString() + (mode != Mode.Clamp ? " & " + mode.ToString() : "");
+        }
+
+        public override bool HasReference(Variable variable)
+        {
+            return lower.floatRef == variable || upper.floatRef == variable || value.floatRef == variable ||
+                   outValue.floatRef == variable;
         }
 
         public override Color GetButtonColor()
diff --git a/Assets/Fungus/Scripts/Commands/Math/Curve.cs b/Assets/Fungus/Scripts/Commands/Math/Curve.cs
index 69c8d76a..9d15bece 100644
--- a/Assets/Fungus/Scripts/Commands/Math/Curve.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/Curve.cs
@@ -20,10 +20,5 @@ namespace Fungus
 
             Continue();
         }
-
-        public override string GetSummary()
-        {
-            return "Curve";
-        }
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Math/Exp.cs b/Assets/Fungus/Scripts/Commands/Math/Exp.cs
index 6e5c4723..5489c1a6 100644
--- a/Assets/Fungus/Scripts/Commands/Math/Exp.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/Exp.cs
@@ -17,10 +17,5 @@ namespace Fungus
 
             Continue();
         }
-
-        public override string GetSummary()
-        {
-            return "Exp";
-        }
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Math/Inv.cs b/Assets/Fungus/Scripts/Commands/Math/Inv.cs
index fcd6a5d3..029761c3 100644
--- a/Assets/Fungus/Scripts/Commands/Math/Inv.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/Inv.cs
@@ -19,10 +19,5 @@ namespace Fungus
 
             Continue();
         }
-
-        public override string GetSummary()
-        {
-            return "Inverse 1/f";
-        }
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Math/InvLerp.cs b/Assets/Fungus/Scripts/Commands/Math/InvLerp.cs
index a593dc0d..a0f86c83 100644
--- a/Assets/Fungus/Scripts/Commands/Math/InvLerp.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/InvLerp.cs
@@ -35,7 +35,16 @@ namespace Fungus
 
         public override string GetSummary()
         {
-            return "InvLerp [" + a.Value.ToString() + "-" + b.Value.ToString() + "]";
+            if (outValue.floatRef == null)
+                return "Error: no out value selected";
+
+            return outValue.floatRef.Key + " = [" + a.Value.ToString() + "-" + b.Value.ToString() + "]";
+        }
+
+        public override bool HasReference(Variable variable)
+        {
+            return a.floatRef == variable || b.floatRef == variable || value.floatRef == variable ||
+                   outValue.floatRef == variable;
         }
 
         public override Color GetButtonColor()
diff --git a/Assets/Fungus/Scripts/Commands/Math/Lerp.cs b/Assets/Fungus/Scripts/Commands/Math/Lerp.cs
index 5caedf46..e98055ae 100644
--- a/Assets/Fungus/Scripts/Commands/Math/Lerp.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/Lerp.cs
@@ -54,6 +54,12 @@ namespace Fungus
             return mode.ToString() + " [" + a.Value.ToString() + "-" + b.Value.ToString() + "]";
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return a.floatRef == variable || b.floatRef == variable || percentage.floatRef == variable ||
+                   outValue.floatRef == variable;
+        }
+
         public override Color GetButtonColor()
         {
             return new Color32(235, 191, 217, 255);
diff --git a/Assets/Fungus/Scripts/Commands/Math/Log.cs b/Assets/Fungus/Scripts/Commands/Math/Log.cs
index 2c7da4bb..8875f974 100644
--- a/Assets/Fungus/Scripts/Commands/Math/Log.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/Log.cs
@@ -40,17 +40,7 @@ namespace Fungus
 
         public override string GetSummary()
         {
-            switch (mode)
-            {
-                case Mode.Base10:
-                    return "Log Base 10";
-                case Mode.Natural:
-                    return "Natural Log";
-                default:
-                    break;
-            }
-
-            return "Log";
+            return mode.ToString() + " " + base.GetSummary();
         }
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Math/Map.cs b/Assets/Fungus/Scripts/Commands/Math/Map.cs
index 61f7fb23..3f653ad4 100644
--- a/Assets/Fungus/Scripts/Commands/Math/Map.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/Map.cs
@@ -40,6 +40,13 @@ namespace Fungus
                 newRangeLower.Value.ToString() + "-" + newRangeUpper.Value.ToString() + "]";
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return initialRangeLower.floatRef == variable || initialRangeUpper.floatRef == variable || value.floatRef == variable ||
+                   newRangeLower.floatRef == variable || newRangeUpper.floatRef == variable ||
+                   outValue.floatRef == variable;
+        }
+
         public override Color GetButtonColor()
         {
             return new Color32(235, 191, 217, 255);
diff --git a/Assets/Fungus/Scripts/Commands/Math/MinMax.cs b/Assets/Fungus/Scripts/Commands/Math/MinMax.cs
index 9efeb0a0..7294454f 100644
--- a/Assets/Fungus/Scripts/Commands/Math/MinMax.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/MinMax.cs
@@ -43,19 +43,24 @@ namespace Fungus
                     break;
             }
 
-
             Continue();
         }
 
         public override string GetSummary()
         {
-            return function.ToString();
+            return function.ToString() + " " +
+                "out: " + (outValue.floatRef != null ? outValue.floatRef.Key : outValue.Value.ToString()) +
+                " [" + inLHSValue.Value.ToString() + " - " + inRHSValue.Value.ToString() + "]";
+        }
+
+        public override bool HasReference(Variable variable)
+        {
+            return inLHSValue.floatRef == variable || inRHSValue.floatRef == variable || outValue.floatRef == variable;
         }
 
         public override Color GetButtonColor()
         {
             return new Color32(235, 191, 217, 255);
         }
-
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Math/Neg.cs b/Assets/Fungus/Scripts/Commands/Math/Neg.cs
index 883ef7de..1f063868 100644
--- a/Assets/Fungus/Scripts/Commands/Math/Neg.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/Neg.cs
@@ -17,10 +17,5 @@ namespace Fungus
 
             Continue();
         }
-
-        public override string GetSummary()
-        {
-            return "Negate";
-        }
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Math/Pow.cs b/Assets/Fungus/Scripts/Commands/Math/Pow.cs
index e20db290..586c43c5 100644
--- a/Assets/Fungus/Scripts/Commands/Math/Pow.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/Pow.cs
@@ -27,7 +27,10 @@ namespace Fungus
 
         public override string GetSummary()
         {
-            return "Pow";
+            if (outValue.floatRef == null)
+                return "Error: No out value selected";
+
+            return outValue.floatRef.Key + " = " + baseValue.Value.ToString() + "^" + exponentValue.Value.ToString();
         }
 
         public override Color GetButtonColor()
@@ -35,5 +38,10 @@ namespace Fungus
             return new Color32(235, 191, 217, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return baseValue.floatRef == variable || exponentValue.floatRef == variable ||
+                   outValue.floatRef == variable;
+        }
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Math/Round.cs b/Assets/Fungus/Scripts/Commands/Math/Round.cs
index 418893f7..d7ddc301 100644
--- a/Assets/Fungus/Scripts/Commands/Math/Round.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/Round.cs
@@ -44,7 +44,7 @@ namespace Fungus
 
         public override string GetSummary()
         {
-            return function.ToString();
+            return function.ToString() + " " + base.GetSummary();
         }
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Math/Sign.cs b/Assets/Fungus/Scripts/Commands/Math/Sign.cs
index d3b3ebb9..89fea7b8 100644
--- a/Assets/Fungus/Scripts/Commands/Math/Sign.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/Sign.cs
@@ -17,10 +17,5 @@ namespace Fungus
 
             Continue();
         }
-
-        public override string GetSummary()
-        {
-            return "Sign";
-        }
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Math/Sqrt.cs b/Assets/Fungus/Scripts/Commands/Math/Sqrt.cs
index 57500efe..d8e9485c 100644
--- a/Assets/Fungus/Scripts/Commands/Math/Sqrt.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/Sqrt.cs
@@ -17,10 +17,5 @@ namespace Fungus
 
             Continue();
         }
-
-        public override string GetSummary()
-        {
-            return "Sqrt";
-        }
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Math/ToInt.cs b/Assets/Fungus/Scripts/Commands/Math/ToInt.cs
index e4a15b24..cf8596ca 100644
--- a/Assets/Fungus/Scripts/Commands/Math/ToInt.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/ToInt.cs
@@ -35,17 +35,17 @@ namespace Fungus
         {
             switch (function)
             {
-                case Mode.RoundToInt:
-                    outValue.Value = Mathf.RoundToInt(inValue.Value);
-                    break;
-                case Mode.FloorToInt:
-                    outValue.Value = Mathf.FloorToInt(inValue.Value);
-                    break;
-                case Mode.CeilToInt:
-                    outValue.Value = Mathf.CeilToInt(inValue.Value);
-                    break;
-                default:
-                    break;
+            case Mode.RoundToInt:
+                outValue.Value = Mathf.RoundToInt(inValue.Value);
+                break;
+            case Mode.FloorToInt:
+                outValue.Value = Mathf.FloorToInt(inValue.Value);
+                break;
+            case Mode.CeilToInt:
+                outValue.Value = Mathf.CeilToInt(inValue.Value);
+                break;
+            default:
+                break;
             }
 
             Continue();
@@ -53,7 +53,9 @@ namespace Fungus
 
         public override string GetSummary()
         {
-            return function.ToString();
+            return function.ToString() + 
+                   " in: " + (inValue.floatRef != null ? inValue.floatRef.Key : inValue.Value.ToString()) + 
+                   ", out: " + (outValue.integerRef != null ? outValue.integerRef.Key : outValue.Value.ToString()); ;
         }
 
         public override Color GetButtonColor()
@@ -61,5 +63,9 @@ namespace Fungus
             return new Color32(235, 191, 217, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return variable == inValue.floatRef || variable == outValue.integerRef;
+        }
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Math/Trig.cs b/Assets/Fungus/Scripts/Commands/Math/Trig.cs
index 998cf902..2ef5b78a 100644
--- a/Assets/Fungus/Scripts/Commands/Math/Trig.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/Trig.cs
@@ -22,8 +22,7 @@ namespace Fungus
             Sin,
             Tan
         }
-
-
+        
         [Tooltip("Trigonometric function to run.")]
         [SerializeField]
         protected Function function = Function.Sin;
@@ -65,13 +64,7 @@ namespace Fungus
 
         public override string GetSummary()
         {
-            return function.ToString();
+            return function.ToString() + " " + base.GetSummary();
         }
-
-        public override Color GetButtonColor()
-        {
-            return new Color32(235, 191, 217, 255);
-        }
-
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Menu.cs b/Assets/Fungus/Scripts/Commands/Menu.cs
index c8ac058a..2af4c1fd 100644
--- a/Assets/Fungus/Scripts/Commands/Menu.cs
+++ b/Assets/Fungus/Scripts/Commands/Menu.cs
@@ -95,6 +95,12 @@ namespace Fungus
             return new Color32(184, 210, 235, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return interactable.booleanRef == variable || hideThisOption.booleanRef == variable ||
+                base.HasReference(variable);
+        }
+
         #endregion
 
         #region ILocalizable implementation
@@ -121,5 +127,18 @@ namespace Fungus
         }
 
         #endregion
+
+        #region Editor caches
+#if UNITY_EDITOR
+        protected override void RefreshVariableCache()
+        {
+            base.RefreshVariableCache();
+
+            var f = GetFlowchart();
+
+            f.DetermineSubstituteVariables(text, referencedVariables);
+        }
+#endif
+        #endregion Editor caches
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/MenuTimer.cs b/Assets/Fungus/Scripts/Commands/MenuTimer.cs
index bec4cffb..cb012224 100644
--- a/Assets/Fungus/Scripts/Commands/MenuTimer.cs
+++ b/Assets/Fungus/Scripts/Commands/MenuTimer.cs
@@ -62,6 +62,12 @@ namespace Fungus
             return new Color32(184, 210, 235, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _duration.floatRef == variable ||
+                base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/MoveAdd.cs b/Assets/Fungus/Scripts/Commands/MoveAdd.cs
index 0d518740..0d7f2352 100644
--- a/Assets/Fungus/Scripts/Commands/MoveAdd.cs
+++ b/Assets/Fungus/Scripts/Commands/MoveAdd.cs
@@ -40,6 +40,12 @@ namespace Fungus
             iTween.MoveAdd(_targetObject.Value, tweenParams);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _offset.vector3Ref == variable ||
+                base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/MoveFrom.cs b/Assets/Fungus/Scripts/Commands/MoveFrom.cs
index 8cc0613b..f6912477 100644
--- a/Assets/Fungus/Scripts/Commands/MoveFrom.cs
+++ b/Assets/Fungus/Scripts/Commands/MoveFrom.cs
@@ -50,6 +50,12 @@ namespace Fungus
             iTween.MoveFrom(_targetObject.Value, tweenParams);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _fromTransform.transformRef == variable || _fromPosition.vector3Ref == variable ||
+                base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/MoveTo.cs b/Assets/Fungus/Scripts/Commands/MoveTo.cs
index aac0e7bc..33ba70cc 100644
--- a/Assets/Fungus/Scripts/Commands/MoveTo.cs
+++ b/Assets/Fungus/Scripts/Commands/MoveTo.cs
@@ -50,6 +50,12 @@ namespace Fungus
             iTween.MoveTo(_targetObject.Value, tweenParams);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _toTransform.transformRef == variable || _toPosition.vector3Ref == variable ||
+                base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/OpenURL.cs b/Assets/Fungus/Scripts/Commands/OpenURL.cs
index a13714fc..f9d67987 100644
--- a/Assets/Fungus/Scripts/Commands/OpenURL.cs
+++ b/Assets/Fungus/Scripts/Commands/OpenURL.cs
@@ -36,6 +36,11 @@ namespace Fungus
             return new Color32(235, 191, 217, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return url.stringRef == variable || base.HasReference(variable);
+        }
+
         #endregion
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/PlayAnimState.cs b/Assets/Fungus/Scripts/Commands/PlayAnimState.cs
index 86983b6f..4738a515 100644
--- a/Assets/Fungus/Scripts/Commands/PlayAnimState.cs
+++ b/Assets/Fungus/Scripts/Commands/PlayAnimState.cs
@@ -53,6 +53,13 @@ namespace Fungus
             return new Color32(170, 204, 169, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return animator.animatorRef == variable || stateName.stringRef == variable || 
+                layer.integerRef == variable || time.floatRef == variable || 
+                base.HasReference(variable);
+        }
+
         #endregion
     }    
 }
diff --git a/Assets/Fungus/Scripts/Commands/PlayUsfxrSound.cs b/Assets/Fungus/Scripts/Commands/PlayUsfxrSound.cs
index b61e005c..c1eacfdd 100644
--- a/Assets/Fungus/Scripts/Commands/PlayUsfxrSound.cs
+++ b/Assets/Fungus/Scripts/Commands/PlayUsfxrSound.cs
@@ -83,6 +83,11 @@ using UnityEngine.Serialization;
             return new Color32(128, 200, 200, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return variable == _SettingsString.stringRef;
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/Priority/FungusPriorityCount.cs b/Assets/Fungus/Scripts/Commands/Priority/FungusPriorityCount.cs
index a1aa957a..69df8bd8 100644
--- a/Assets/Fungus/Scripts/Commands/Priority/FungusPriorityCount.cs
+++ b/Assets/Fungus/Scripts/Commands/Priority/FungusPriorityCount.cs
@@ -30,5 +30,10 @@ namespace Fungus
             }
             return outVar.Key;
         }
+
+        public override bool HasReference(Variable variable)
+        {
+            return outVar == variable;
+        }
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/PunchPosition.cs b/Assets/Fungus/Scripts/Commands/PunchPosition.cs
index 4f02620c..ff7b0b0a 100644
--- a/Assets/Fungus/Scripts/Commands/PunchPosition.cs
+++ b/Assets/Fungus/Scripts/Commands/PunchPosition.cs
@@ -40,6 +40,11 @@ namespace Fungus
             iTween.PunchPosition(_targetObject.Value, tweenParams);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return variable == _amount.vector3Ref;
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/PunchRotation.cs b/Assets/Fungus/Scripts/Commands/PunchRotation.cs
index 4fab9d73..71fec5b9 100644
--- a/Assets/Fungus/Scripts/Commands/PunchRotation.cs
+++ b/Assets/Fungus/Scripts/Commands/PunchRotation.cs
@@ -40,6 +40,11 @@ namespace Fungus
             iTween.PunchRotation(_targetObject.Value, tweenParams);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return variable == _amount.vector3Ref;
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/PunchScale.cs b/Assets/Fungus/Scripts/Commands/PunchScale.cs
index 2775eec2..7523520e 100644
--- a/Assets/Fungus/Scripts/Commands/PunchScale.cs
+++ b/Assets/Fungus/Scripts/Commands/PunchScale.cs
@@ -36,6 +36,11 @@ namespace Fungus
             iTween.PunchScale(_targetObject.Value, tweenParams);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return variable == _amount.vector3Ref;
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/RandomFloat.cs b/Assets/Fungus/Scripts/Commands/RandomFloat.cs
index 8ebcbcbc..1cfd5527 100644
--- a/Assets/Fungus/Scripts/Commands/RandomFloat.cs
+++ b/Assets/Fungus/Scripts/Commands/RandomFloat.cs
@@ -48,7 +48,7 @@ namespace Fungus
 
         public override bool HasReference(Variable variable)
         {
-            return (variable == this.variable);
+            return (variable == this.variable) || minValue.floatRef == variable || maxValue.floatRef == variable;
         }
 
         public override Color GetButtonColor()
diff --git a/Assets/Fungus/Scripts/Commands/RandomInteger.cs b/Assets/Fungus/Scripts/Commands/RandomInteger.cs
index 7e238a90..aa201df5 100644
--- a/Assets/Fungus/Scripts/Commands/RandomInteger.cs
+++ b/Assets/Fungus/Scripts/Commands/RandomInteger.cs
@@ -48,7 +48,7 @@ namespace Fungus
 
         public override bool HasReference(Variable variable)
         {
-            return (variable == this.variable);
+            return (variable == this.variable) || minValue.integerRef == variable || maxValue.integerRef == variable;
         }
 
         public override Color GetButtonColor()
diff --git a/Assets/Fungus/Scripts/Commands/ResetAnimTrigger.cs b/Assets/Fungus/Scripts/Commands/ResetAnimTrigger.cs
index f43c4774..baf3b277 100644
--- a/Assets/Fungus/Scripts/Commands/ResetAnimTrigger.cs
+++ b/Assets/Fungus/Scripts/Commands/ResetAnimTrigger.cs
@@ -49,6 +49,12 @@ namespace Fungus
             return new Color32(170, 204, 169, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _animator.animatorRef == variable || _parameterName.stringRef == variable ||
+                base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/RotateAdd.cs b/Assets/Fungus/Scripts/Commands/RotateAdd.cs
index f4dcd663..cf35b0dd 100644
--- a/Assets/Fungus/Scripts/Commands/RotateAdd.cs
+++ b/Assets/Fungus/Scripts/Commands/RotateAdd.cs
@@ -40,6 +40,12 @@ namespace Fungus
             iTween.RotateAdd(_targetObject.Value, tweenParams);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _offset.vector3Ref == variable ||
+                base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/RotateFrom.cs b/Assets/Fungus/Scripts/Commands/RotateFrom.cs
index f3797fde..46224268 100644
--- a/Assets/Fungus/Scripts/Commands/RotateFrom.cs
+++ b/Assets/Fungus/Scripts/Commands/RotateFrom.cs
@@ -50,6 +50,12 @@ namespace Fungus
             iTween.RotateFrom(_targetObject.Value, tweenParams);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _fromTransform.transformRef == variable || _fromRotation.vector3Ref == variable ||
+                base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/RotateTo.cs b/Assets/Fungus/Scripts/Commands/RotateTo.cs
index 1a6a1b33..7f5bcf74 100644
--- a/Assets/Fungus/Scripts/Commands/RotateTo.cs
+++ b/Assets/Fungus/Scripts/Commands/RotateTo.cs
@@ -50,6 +50,12 @@ namespace Fungus
             iTween.RotateTo(_targetObject.Value, tweenParams);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _toTransform.transformRef == variable || _toRotation.vector3Ref == variable ||
+                base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/SaveVariable.cs b/Assets/Fungus/Scripts/Commands/SaveVariable.cs
index 43933880..4a5522d9 100644
--- a/Assets/Fungus/Scripts/Commands/SaveVariable.cs
+++ b/Assets/Fungus/Scripts/Commands/SaveVariable.cs
@@ -103,6 +103,23 @@ namespace Fungus
             return new Color32(235, 191, 217, 255);
         }
 
+        public override bool HasReference(Variable in_variable)
+        {
+            return this.variable == in_variable || base.HasReference(in_variable);
+        }
+
         #endregion
-    }    
+        #region Editor caches
+#if UNITY_EDITOR
+        protected override void RefreshVariableCache()
+        {
+            base.RefreshVariableCache();
+
+            var f = GetFlowchart();
+
+            f.DetermineSubstituteVariables(key, referencedVariables);
+        }
+#endif
+        #endregion Editor caches
+    }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/ScaleAdd.cs b/Assets/Fungus/Scripts/Commands/ScaleAdd.cs
index 6dd633f2..be4e56f2 100644
--- a/Assets/Fungus/Scripts/Commands/ScaleAdd.cs
+++ b/Assets/Fungus/Scripts/Commands/ScaleAdd.cs
@@ -36,6 +36,12 @@ namespace Fungus
             iTween.ScaleAdd(_targetObject.Value, tweenParams);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _offset.vector3Ref == variable ||
+                base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/ScaleFrom.cs b/Assets/Fungus/Scripts/Commands/ScaleFrom.cs
index 1376c2ab..7c317f2a 100644
--- a/Assets/Fungus/Scripts/Commands/ScaleFrom.cs
+++ b/Assets/Fungus/Scripts/Commands/ScaleFrom.cs
@@ -46,6 +46,12 @@ namespace Fungus
             iTween.ScaleFrom(_targetObject.Value, tweenParams);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _fromTransform.transformRef == variable || _fromScale.vector3Ref == variable ||
+                base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/ScaleTo.cs b/Assets/Fungus/Scripts/Commands/ScaleTo.cs
index 4baeb3e5..3a80d57a 100644
--- a/Assets/Fungus/Scripts/Commands/ScaleTo.cs
+++ b/Assets/Fungus/Scripts/Commands/ScaleTo.cs
@@ -46,6 +46,12 @@ namespace Fungus
             iTween.ScaleTo(_targetObject.Value, tweenParams);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _toTransform.transformRef == variable || _toScale.vector3Ref == variable ||
+                base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/SendMessage.cs b/Assets/Fungus/Scripts/Commands/SendMessage.cs
index fd87b76d..995fc09c 100644
--- a/Assets/Fungus/Scripts/Commands/SendMessage.cs
+++ b/Assets/Fungus/Scripts/Commands/SendMessage.cs
@@ -84,6 +84,11 @@ namespace Fungus
             return new Color32(235, 191, 217, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _message.stringRef == variable || base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/SetActive.cs b/Assets/Fungus/Scripts/Commands/SetActive.cs
index 4a6f11bc..bafc947e 100644
--- a/Assets/Fungus/Scripts/Commands/SetActive.cs
+++ b/Assets/Fungus/Scripts/Commands/SetActive.cs
@@ -49,6 +49,12 @@ namespace Fungus
             return new Color32(235, 191, 217, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _targetGameObject.gameObjectRef == variable || activeState.booleanRef == variable || 
+                base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/SetAnimBool.cs b/Assets/Fungus/Scripts/Commands/SetAnimBool.cs
index a4b9290d..26a7a778 100644
--- a/Assets/Fungus/Scripts/Commands/SetAnimBool.cs
+++ b/Assets/Fungus/Scripts/Commands/SetAnimBool.cs
@@ -52,6 +52,12 @@ namespace Fungus
             return new Color32(170, 204, 169, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _animator.animatorRef == variable || _parameterName.stringRef == variable || value.booleanRef == variable ||
+                base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/SetAnimFloat.cs b/Assets/Fungus/Scripts/Commands/SetAnimFloat.cs
index 9494e542..5aa66f55 100644
--- a/Assets/Fungus/Scripts/Commands/SetAnimFloat.cs
+++ b/Assets/Fungus/Scripts/Commands/SetAnimFloat.cs
@@ -52,6 +52,12 @@ namespace Fungus
             return new Color32(170, 204, 169, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _animator.animatorRef == variable || _parameterName.stringRef == variable || value.floatRef == variable ||
+                base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/SetAnimInteger.cs b/Assets/Fungus/Scripts/Commands/SetAnimInteger.cs
index 8f07d4fd..cb4e8076 100644
--- a/Assets/Fungus/Scripts/Commands/SetAnimInteger.cs
+++ b/Assets/Fungus/Scripts/Commands/SetAnimInteger.cs
@@ -52,6 +52,12 @@ namespace Fungus
             return new Color32(170, 204, 169, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _animator.animatorRef == variable || _parameterName.stringRef == variable || value.integerRef == variable || 
+                base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/SetAnimTrigger.cs b/Assets/Fungus/Scripts/Commands/SetAnimTrigger.cs
index d7843e7a..a3d190cc 100644
--- a/Assets/Fungus/Scripts/Commands/SetAnimTrigger.cs
+++ b/Assets/Fungus/Scripts/Commands/SetAnimTrigger.cs
@@ -49,6 +49,11 @@ namespace Fungus
             return new Color32(170, 204, 169, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _animator.animatorRef == variable || _parameterName.stringRef == variable || base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/SetClickable2D.cs b/Assets/Fungus/Scripts/Commands/SetClickable2D.cs
index 80138ed7..29a59de9 100644
--- a/Assets/Fungus/Scripts/Commands/SetClickable2D.cs
+++ b/Assets/Fungus/Scripts/Commands/SetClickable2D.cs
@@ -44,7 +44,12 @@ namespace Fungus
         
         public override Color GetButtonColor()
         {
-            return new Color32(235, 191, 217, 255); 
+            return new Color32(235, 191, 217, 255);
+        }
+
+        public override bool HasReference(Variable variable)
+        {
+            return activeState.booleanRef == variable || base.HasReference(variable);
         }
 
         #endregion
diff --git a/Assets/Fungus/Scripts/Commands/SetCollider.cs b/Assets/Fungus/Scripts/Commands/SetCollider.cs
index ef623040..2cca14f8 100644
--- a/Assets/Fungus/Scripts/Commands/SetCollider.cs
+++ b/Assets/Fungus/Scripts/Commands/SetCollider.cs
@@ -102,6 +102,11 @@ namespace Fungus
             return propertyName == "targetObjects";
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return activeState.booleanRef == variable || base.HasReference(variable);
+        }
+
         #endregion
     }
         
diff --git a/Assets/Fungus/Scripts/Commands/SetDraggable2D.cs b/Assets/Fungus/Scripts/Commands/SetDraggable2D.cs
index c5e0ff6a..3b8ac1ef 100644
--- a/Assets/Fungus/Scripts/Commands/SetDraggable2D.cs
+++ b/Assets/Fungus/Scripts/Commands/SetDraggable2D.cs
@@ -47,6 +47,11 @@ namespace Fungus
             return new Color32(235, 191, 217, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return activeState.booleanRef == variable || base.HasReference(variable);
+        }
+
         #endregion
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/SetInteractable.cs b/Assets/Fungus/Scripts/Commands/SetInteractable.cs
index e258883c..ea2d0912 100644
--- a/Assets/Fungus/Scripts/Commands/SetInteractable.cs
+++ b/Assets/Fungus/Scripts/Commands/SetInteractable.cs
@@ -101,6 +101,11 @@ namespace Fungus
             return false;
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return interactableState.booleanRef == variable || base.HasReference(variable);
+        }
+
         #endregion
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/SetLanguage.cs b/Assets/Fungus/Scripts/Commands/SetLanguage.cs
index 2c6aae9f..9efc8867 100644
--- a/Assets/Fungus/Scripts/Commands/SetLanguage.cs
+++ b/Assets/Fungus/Scripts/Commands/SetLanguage.cs
@@ -48,6 +48,11 @@ namespace Fungus
             return new Color32(184, 210, 235, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _languageCode.stringRef == variable || base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/SetSliderValue.cs b/Assets/Fungus/Scripts/Commands/SetSliderValue.cs
index cfde6251..f80b06c9 100644
--- a/Assets/Fungus/Scripts/Commands/SetSliderValue.cs
+++ b/Assets/Fungus/Scripts/Commands/SetSliderValue.cs
@@ -47,6 +47,11 @@ namespace Fungus
             return slider.name + " = " + value.GetDescription();
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return value.floatRef == variable || base.HasReference(variable);
+        }
+
         #endregion
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/SetSprite.cs b/Assets/Fungus/Scripts/Commands/SetSprite.cs
new file mode 100644
index 00000000..8a2d7cdd
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/SetSprite.cs
@@ -0,0 +1,87 @@
+// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+// Snippet added by ducksonthewater, 2019-01-03 - www.ducks-on-the-water.com
+
+using UnityEngine;
+using System.Collections.Generic;
+
+namespace Fungus
+{
+    /// <summary>
+    /// Changes the sprite on a SpriteRenderer.
+    /// </summary>
+    [CommandInfo("Sprite", 
+                 "Set Sprite", 
+                 "Changes the sprite property of a list of Sprite Renderers.")]
+    [AddComponentMenu("")]
+    public class SetSprite : Command 
+    {
+        [Tooltip("List of sprites to set the sprite property on")]
+        [SerializeField] protected List<SpriteRenderer> spriteRenderers = new List<SpriteRenderer>();
+
+        [Tooltip("The sprite set on the target sprite renderers")]
+        [SerializeField] protected Sprite sprite;
+
+        #region Public members
+
+        public override void OnEnter()
+        {
+            for (int i = 0; i < spriteRenderers.Count; i++)
+            {
+                var spriteRenderer = spriteRenderers[i];
+                spriteRenderer.sprite = sprite;
+            }
+
+            Continue();
+        }
+        
+        public override string GetSummary()
+        {
+            string summary = "";
+            for (int i = 0; i < spriteRenderers.Count; i++)
+            {
+                var spriteRenderer = spriteRenderers[i];
+                if (spriteRenderer == null)
+                {
+                    continue;
+                }
+                if (summary.Length > 0)
+                {
+                    summary += ", ";
+                }
+                summary += spriteRenderer.name;
+            }
+
+            if (summary.Length == 0)
+            {
+                return "Error: No sprite selected";
+            }
+
+            return summary + " = " + sprite;
+        }
+        
+        public override Color GetButtonColor()
+        {
+            return new Color32(235, 191, 217, 255);
+        }
+
+        public override bool IsReorderableArray(string propertyName)
+        {
+            if (propertyName == "spriteRenderers")
+            {
+                return true;
+            }
+
+            return false;
+        }
+
+        public override void OnCommandAdded(Block parentBlock)
+        {
+            // Add a default empty entry
+            spriteRenderers.Add(null);
+        }
+
+        #endregion
+    }
+}
diff --git a/Assets/Fungus/Scripts/Commands/SetSprite.cs.meta b/Assets/Fungus/Scripts/Commands/SetSprite.cs.meta
new file mode 100644
index 00000000..aa8315a2
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/SetSprite.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 8bacd6d8da56644cbb2c9a43f96750c3
+timeCreated: 1439385260
+licenseType: Store
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 
diff --git a/Assets/Fungus/Scripts/Commands/SetSpriteOrder.cs b/Assets/Fungus/Scripts/Commands/SetSpriteOrder.cs
index e284941d..fb811b6b 100644
--- a/Assets/Fungus/Scripts/Commands/SetSpriteOrder.cs
+++ b/Assets/Fungus/Scripts/Commands/SetSpriteOrder.cs
@@ -80,6 +80,11 @@ namespace Fungus
             targetSprites.Add(null);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return orderInLayer.integerRef == variable || base.HasReference(variable);
+        }
+
         #endregion
     }
 }
diff --git a/Assets/Fungus/Scripts/Commands/SetText.cs b/Assets/Fungus/Scripts/Commands/SetText.cs
index 14c54b8b..500dd011 100644
--- a/Assets/Fungus/Scripts/Commands/SetText.cs
+++ b/Assets/Fungus/Scripts/Commands/SetText.cs
@@ -65,8 +65,27 @@ namespace Fungus
             return new Color32(235, 191, 217, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return text.stringRef == variable || base.HasReference(variable);
+        }
+
         #endregion
 
+
+        #region Editor caches
+#if UNITY_EDITOR
+        protected override void RefreshVariableCache()
+        {
+            base.RefreshVariableCache();
+
+            var f = GetFlowchart();
+
+            f.DetermineSubstituteVariables(text, referencedVariables);
+        }
+#endif
+        #endregion Editor caches
+
         #region ILocalizable implementation
 
         public virtual string GetStandardText()
diff --git a/Assets/Fungus/Scripts/Commands/SetToggleState.cs b/Assets/Fungus/Scripts/Commands/SetToggleState.cs
index 79d9f376..d93a0262 100644
--- a/Assets/Fungus/Scripts/Commands/SetToggleState.cs
+++ b/Assets/Fungus/Scripts/Commands/SetToggleState.cs
@@ -47,6 +47,11 @@ namespace Fungus
             return toggle.name + " = " + value.GetDescription();
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return value.booleanRef == variable || base.HasReference(variable);
+        }
+
         #endregion
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/SetUIImage.cs b/Assets/Fungus/Scripts/Commands/SetUIImage.cs
new file mode 100644
index 00000000..b30939e1
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/SetUIImage.cs
@@ -0,0 +1,86 @@
+// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+using System.Collections.Generic;
+using UnityEngine.UI;
+
+namespace Fungus
+{
+    /// <summary>
+    /// Changes the Image property on a UI element.
+    /// </summary>
+    [CommandInfo("UI", 
+                 "Set UI Image", 
+                 "Changes the Image property of a list of UI Images.")]
+    [AddComponentMenu("")]
+    public class SetUIImage : Command 
+    {
+        [Tooltip("List of UI Images to set the source image property on")]
+        [SerializeField] protected List<Image> images = new List<Image>();
+
+        [Tooltip("The sprite set on the source image property")]
+        [SerializeField] protected Sprite sprite;
+
+        #region Public members
+
+        public override void OnEnter()
+        {
+            for (int i = 0; i < images.Count; i++)
+            {
+                var image = images[i];
+                image.sprite = sprite;
+            }
+
+            Continue();
+        }
+        
+        public override string GetSummary()
+        {
+            string summary = "";
+            for (int i = 0; i < images.Count; i++)
+            {
+                var targetImage = images[i];
+                if (targetImage == null)
+                {
+                    continue;
+                }
+                if (summary.Length > 0)
+                {
+                    summary += ", ";
+                }
+                summary += targetImage.name;
+            }
+
+            if (summary.Length == 0)
+            {
+                return "Error: No sprite selected";
+            }
+
+            return summary + " = " + sprite;
+        }
+        
+        public override Color GetButtonColor()
+        {
+            return new Color32(235, 191, 217, 255);
+        }
+
+        public override bool IsReorderableArray(string propertyName)
+        {
+            if (propertyName == "images")
+            {
+                return true;
+            }
+
+            return false;
+        }
+
+        public override void OnCommandAdded(Block parentBlock)
+        {
+            // Add a default empty entry
+            images.Add(null);
+        }
+
+        #endregion
+    }
+}
diff --git a/Assets/Fungus/Scripts/Commands/SetUIImage.cs.meta b/Assets/Fungus/Scripts/Commands/SetUIImage.cs.meta
new file mode 100644
index 00000000..39b80ddf
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/SetUIImage.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 82e4c082f762243f6943909a4272096d
+timeCreated: 1439385260
+licenseType: Store
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 
diff --git a/Assets/Fungus/Scripts/Commands/SetVariable.cs b/Assets/Fungus/Scripts/Commands/SetVariable.cs
index 98e3f3ba..50ca8588 100644
--- a/Assets/Fungus/Scripts/Commands/SetVariable.cs
+++ b/Assets/Fungus/Scripts/Commands/SetVariable.cs
@@ -92,83 +92,86 @@ namespace Fungus
                 return;
             }
 
-            if (variable.GetType() == typeof(BooleanVariable))
+
+            var t = variable.GetType();
+
+            if (t == typeof(BooleanVariable))
             {
                 BooleanVariable booleanVariable = (variable as BooleanVariable);
                 booleanVariable.Apply(setOperator, booleanData.Value);
             }
-            else if (variable.GetType() == typeof(IntegerVariable))
+            else if (t == typeof(IntegerVariable))
             {
                 IntegerVariable integerVariable = (variable as IntegerVariable);
                 integerVariable.Apply(setOperator, integerData.Value);
             }
-            else if (variable.GetType() == typeof(FloatVariable))
+            else if (t == typeof(FloatVariable))
             {
                 FloatVariable floatVariable = (variable as FloatVariable);
                 floatVariable.Apply(setOperator, floatData.Value);
             }
-            else if (variable.GetType() == typeof(StringVariable))
+            else if (t == typeof(StringVariable))
             {
                 StringVariable stringVariable = (variable as StringVariable);
                 var flowchart = GetFlowchart();
                 stringVariable.Apply(setOperator, flowchart.SubstituteVariables(stringData.Value));
             }
-            else if (variable.GetType() == typeof(AnimatorVariable))
+            else if (t == typeof(AnimatorVariable))
             {
                 AnimatorVariable animatorVariable = (variable as AnimatorVariable);
                 animatorVariable.Apply(setOperator, animatorData.Value);
             }
-            else if (variable.GetType() == typeof(AudioSourceVariable))
+            else if (t == typeof(AudioSourceVariable))
             {
                 AudioSourceVariable audioSourceVariable = (variable as AudioSourceVariable);
                 audioSourceVariable.Apply(setOperator, audioSourceData.Value);
             }
-            else if (variable.GetType() == typeof(ColorVariable))
+            else if (t == typeof(ColorVariable))
             {
                 ColorVariable colorVariable = (variable as ColorVariable);
                 colorVariable.Apply(setOperator, colorData.Value);
             }
-            else if (variable.GetType() == typeof(GameObjectVariable))
+            else if (t == typeof(GameObjectVariable))
             {
                 GameObjectVariable gameObjectVariable = (variable as GameObjectVariable);
                 gameObjectVariable.Apply(setOperator, gameObjectData.Value);
             }
-            else if (variable.GetType() == typeof(MaterialVariable))
+            else if (t == typeof(MaterialVariable))
             {
                 MaterialVariable materialVariable = (variable as MaterialVariable);
                 materialVariable.Apply(setOperator, materialData.Value);
             }
-            else if (variable.GetType() == typeof(ObjectVariable))
+            else if (t == typeof(ObjectVariable))
             {
                 ObjectVariable objectVariable = (variable as ObjectVariable);
                 objectVariable.Apply(setOperator, objectData.Value);
             }
-            else if (variable.GetType() == typeof(Rigidbody2DVariable))
+            else if (t == typeof(Rigidbody2DVariable))
             {
                 Rigidbody2DVariable rigidbody2DVariable = (variable as Rigidbody2DVariable);
                 rigidbody2DVariable.Apply(setOperator, rigidbody2DData.Value);
             }
-            else if (variable.GetType() == typeof(SpriteVariable))
+            else if (t == typeof(SpriteVariable))
             {
                 SpriteVariable spriteVariable = (variable as SpriteVariable);
                 spriteVariable.Apply(setOperator, spriteData.Value);
             }
-            else if (variable.GetType() == typeof(TextureVariable))
+            else if (t == typeof(TextureVariable))
             {
                 TextureVariable textureVariable = (variable as TextureVariable);
                 textureVariable.Apply(setOperator, textureData.Value);
             }
-            else if (variable.GetType() == typeof(TransformVariable))
+            else if (t == typeof(TransformVariable))
             {
                 TransformVariable transformVariable = (variable as TransformVariable);
                 transformVariable.Apply(setOperator, transformData.Value);
             }
-            else if (variable.GetType() == typeof(Vector2Variable))
+            else if (t == typeof(Vector2Variable))
             {
                 Vector2Variable vector2Variable = (variable as Vector2Variable);
                 vector2Variable.Apply(setOperator, vector2Data.Value);
             }
-            else if (variable.GetType() == typeof(Vector3Variable))
+            else if (t == typeof(Vector3Variable))
             {
                 Vector3Variable vector3Variable = (variable as Vector3Variable);
                 vector3Variable.Apply(setOperator, vector3Data.Value);
@@ -240,67 +243,69 @@ namespace Fungus
                 break;
             }
 
-            if (variable.GetType() == typeof(BooleanVariable))
+            var t = variable.GetType();
+
+            if (t == typeof(BooleanVariable))
             {
                 description += booleanData.GetDescription();
             }
-            else if (variable.GetType() == typeof(IntegerVariable))
+            else if (t == typeof(IntegerVariable))
             {
                 description += integerData.GetDescription();
             }
-            else if (variable.GetType() == typeof(FloatVariable))
+            else if (t == typeof(FloatVariable))
             {
                 description += floatData.GetDescription();
             }
-            else if (variable.GetType() == typeof(StringVariable))
+            else if (t == typeof(StringVariable))
             {
                 description += stringData.GetDescription();
             }
-            else if (variable.GetType() == typeof(AnimatorVariable))
+            else if (t == typeof(AnimatorVariable))
             {
                 description += animatorData.GetDescription();
             }
-            else if (variable.GetType() == typeof(AudioSourceVariable))
+            else if (t == typeof(AudioSourceVariable))
             {
                 description += audioSourceData.GetDescription();
             }
-            else if (variable.GetType() == typeof(ColorVariable))
+            else if (t == typeof(ColorVariable))
             {
                 description += colorData.GetDescription();
             }
-            else if (variable.GetType() == typeof(GameObjectVariable))
+            else if (t == typeof(GameObjectVariable))
             {
                 description += gameObjectData.GetDescription();
             }
-            else if (variable.GetType() == typeof(MaterialVariable))
+            else if (t == typeof(MaterialVariable))
             {
                 description += materialData.GetDescription();
             }
-            else if (variable.GetType() == typeof(ObjectVariable))
+            else if (t == typeof(ObjectVariable))
             {
                 description += objectData.GetDescription();
             }
-            else if (variable.GetType() == typeof(Rigidbody2DVariable))
+            else if (t == typeof(Rigidbody2DVariable))
             {
                 description += rigidbody2DData.GetDescription();
             }
-            else if (variable.GetType() == typeof(SpriteVariable))
+            else if (t == typeof(SpriteVariable))
             {
                 description += spriteData.GetDescription();
             }
-            else if (variable.GetType() == typeof(TextureVariable))
+            else if (t == typeof(TextureVariable))
             {
                 description += textureData.GetDescription();
             }
-            else if (variable.GetType() == typeof(TransformVariable))
+            else if (t == typeof(TransformVariable))
             {
                 description += transformData.GetDescription();
             }
-            else if (variable.GetType() == typeof(Vector2Variable))
+            else if (t == typeof(Vector2Variable))
             {
                 description += vector2Data.GetDescription();
             }
-            else if (variable.GetType() == typeof(Vector3Variable))
+            else if (t == typeof(Vector3Variable))
             {
                 description += vector3Data.GetDescription();
             }
@@ -310,7 +315,77 @@ namespace Fungus
 
         public override bool HasReference(Variable variable)
         {
-            return (variable == this.variable);
+            bool retval = (variable == this.variable) || base.HasReference(variable);
+
+            var t = variable.GetType();
+
+            //this is a nightmare
+            if (t == typeof(BooleanVariable))
+            {
+                retval |= booleanData.booleanRef == variable;
+            }
+            else if (t == typeof(IntegerVariable))
+            {
+                retval |= integerData.integerRef == variable;
+            }
+            else if (t == typeof(FloatVariable))
+            {
+                retval |= floatData.floatRef == variable;
+            }
+            else if (t == typeof(StringVariable))
+            {
+                retval |= stringData.stringRef == variable;
+            }
+            else if (t == typeof(AnimatorVariable))
+            {
+                retval |= animatorData.animatorRef == variable;
+            }
+            else if (t == typeof(AudioSourceVariable))
+            {
+                retval |= audioSourceData.audioSourceRef == variable;
+            }
+            else if (t == typeof(ColorVariable))
+            {
+                retval |= colorData.colorRef == variable;
+            }
+            else if (t == typeof(GameObjectVariable))
+            {
+                retval |= gameObjectData.gameObjectRef == variable;
+            }
+            else if (t == typeof(MaterialVariable))
+            {
+                retval |= materialData.materialRef == variable;
+            }
+            else if (t == typeof(ObjectVariable))
+            {
+                retval |= objectData.objectRef == variable;
+            }
+            else if (t == typeof(Rigidbody2DVariable))
+            {
+                retval |= rigidbody2DData.rigidbody2DRef == variable;
+            }
+            else if (t == typeof(SpriteVariable))
+            {
+                retval |= spriteData.spriteRef == variable;
+            }
+            else if (t == typeof(TextureVariable))
+            {
+                retval |= textureData.textureRef == variable;
+            }
+            else if (t == typeof(TransformVariable))
+            {
+                retval |= transformData.transformRef == variable;
+            }
+            else if (t == typeof(Vector2Variable))
+            {
+                retval |= vector2Data.vector2Ref == variable;
+            }
+            else if (t == typeof(Vector3Variable))
+            {
+                retval |= vector3Data.vector3Ref == variable;
+            }
+
+            return retval;
         }
 
         public override Color GetButtonColor()
@@ -319,5 +394,18 @@ namespace Fungus
         }
 
         #endregion
+
+        #region Editor caches
+#if UNITY_EDITOR
+        protected override void RefreshVariableCache()
+        {
+            base.RefreshVariableCache();
+
+            var f = GetFlowchart();
+
+            f.DetermineSubstituteVariables(stringData.Value, referencedVariables);
+        }
+#endif
+        #endregion Editor caches
     }
 }
diff --git a/Assets/Fungus/Scripts/Commands/ShakePosition.cs b/Assets/Fungus/Scripts/Commands/ShakePosition.cs
index 4432d068..2388a0b2 100644
--- a/Assets/Fungus/Scripts/Commands/ShakePosition.cs
+++ b/Assets/Fungus/Scripts/Commands/ShakePosition.cs
@@ -55,6 +55,11 @@ namespace Fungus
             iTween.ShakePosition(_targetObject.Value, tweenParams);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _amount.vector3Ref == variable || base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/ShakeRotation.cs b/Assets/Fungus/Scripts/Commands/ShakeRotation.cs
index a4838efd..ab30c1d8 100644
--- a/Assets/Fungus/Scripts/Commands/ShakeRotation.cs
+++ b/Assets/Fungus/Scripts/Commands/ShakeRotation.cs
@@ -40,6 +40,11 @@ namespace Fungus
             iTween.ShakeRotation(_targetObject.Value, tweenParams);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _amount.vector3Ref == variable || base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/ShakeScale.cs b/Assets/Fungus/Scripts/Commands/ShakeScale.cs
index 6a3434d4..c2c0ffca 100644
--- a/Assets/Fungus/Scripts/Commands/ShakeScale.cs
+++ b/Assets/Fungus/Scripts/Commands/ShakeScale.cs
@@ -36,6 +36,11 @@ namespace Fungus
             iTween.ShakeScale(_targetObject.Value, tweenParams);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _amount.vector3Ref == variable || base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/ShowSprite.cs b/Assets/Fungus/Scripts/Commands/ShowSprite.cs
index 110b6517..ea454a50 100644
--- a/Assets/Fungus/Scripts/Commands/ShowSprite.cs
+++ b/Assets/Fungus/Scripts/Commands/ShowSprite.cs
@@ -71,6 +71,11 @@ namespace Fungus
             return new Color32(221, 184, 169, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _visible.booleanRef == variable || base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/StopBlock.cs b/Assets/Fungus/Scripts/Commands/StopBlock.cs
index 125045d4..4f390591 100644
--- a/Assets/Fungus/Scripts/Commands/StopBlock.cs
+++ b/Assets/Fungus/Scripts/Commands/StopBlock.cs
@@ -55,6 +55,11 @@ namespace Fungus
             return new Color32(253, 253, 150, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return blockName.stringRef == variable || base.HasReference(variable);
+        }
+
         #endregion
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/StopTween.cs b/Assets/Fungus/Scripts/Commands/StopTween.cs
index 059bf75e..f1cd8d11 100644
--- a/Assets/Fungus/Scripts/Commands/StopTween.cs
+++ b/Assets/Fungus/Scripts/Commands/StopTween.cs
@@ -27,6 +27,11 @@ namespace Fungus
             Continue();
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _tweenName.stringRef == variable || base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/ToString.cs b/Assets/Fungus/Scripts/Commands/ToString.cs
new file mode 100644
index 00000000..653a4e7a
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/ToString.cs
@@ -0,0 +1,63 @@
+// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+    /// <summary>
+    /// Stores the result of a ToString on given variable in a string.
+    /// </summary>
+    [CommandInfo("Variable",
+                 "To String",
+                 "Stores the result of a ToString on given variable in a string.")]
+    [AddComponentMenu("")]
+    public class ToString : Command
+    {
+        [Tooltip("Target variable to get String of.")]
+        [VariableProperty()]
+        [SerializeField] protected Variable variable;
+
+        [Tooltip("Variable to store the result of ToString")]
+        [VariableProperty(typeof(StringVariable))]
+        [SerializeField] protected StringVariable outValue;
+
+        //[Tooltip("Optional formatting string given to ToString")]
+        //[SerializeField] protected StringData format;
+
+        public override void OnEnter()
+        {
+            if (variable != null && outValue != null)
+            {
+                outValue.Value = variable.ToString();
+            }
+
+            Continue();
+        }
+
+        public override string GetSummary()
+        {
+            if (variable == null)
+            {
+                return "Error: Variable not selected";
+            }
+
+            if (outValue == null)
+            {
+                return "Error: outValue not set";
+            }
+
+            return outValue.Key + " = " + variable.Key + ".ToString";
+        }
+
+        public override bool HasReference(Variable variable)
+        {
+            return (variable == this.variable) || outValue == variable;
+        }
+
+        public override Color GetButtonColor()
+        {
+            return new Color32(253, 253, 150, 255);
+        }
+    }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/ToString.cs.meta b/Assets/Fungus/Scripts/Commands/ToString.cs.meta
new file mode 100644
index 00000000..1668c940
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/ToString.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: e76deb01172e9c64c9f78361b06b85bd
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 
diff --git a/Assets/Fungus/Scripts/Commands/TweenUI.cs b/Assets/Fungus/Scripts/Commands/TweenUI.cs
index 2563c796..1a7e62f0 100644
--- a/Assets/Fungus/Scripts/Commands/TweenUI.cs
+++ b/Assets/Fungus/Scripts/Commands/TweenUI.cs
@@ -132,6 +132,11 @@ namespace Fungus
             return false;
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return waitUntilFinished.booleanRef == variable || duration.floatRef == variable || base.HasReference(variable);
+        }
+
         #endregion
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/VariableCondition.cs b/Assets/Fungus/Scripts/Commands/VariableCondition.cs
index f69db54f..a1ab567a 100644
--- a/Assets/Fungus/Scripts/Commands/VariableCondition.cs
+++ b/Assets/Fungus/Scripts/Commands/VariableCondition.cs
@@ -87,82 +87,84 @@ namespace Fungus
 
             bool condition = false;
 
-            if (variable.GetType() == typeof(BooleanVariable))
+            var t = variable.GetType();
+
+            if (t == typeof(BooleanVariable))
             {
                 BooleanVariable booleanVariable = (variable as BooleanVariable);
                 condition = booleanVariable.Evaluate(compareOperator, booleanData.Value);
             }
-            else if (variable.GetType() == typeof(IntegerVariable))
+            else if (t == typeof(IntegerVariable))
             {
                 IntegerVariable integerVariable = (variable as IntegerVariable);
                 condition = integerVariable.Evaluate(compareOperator, integerData.Value);
             }
-            else if (variable.GetType() == typeof(FloatVariable))
+            else if (t == typeof(FloatVariable))
             {
                 FloatVariable floatVariable = (variable as FloatVariable);
                 condition = floatVariable.Evaluate(compareOperator, floatData.Value);
             }
-            else if (variable.GetType() == typeof(StringVariable))
+            else if (t == typeof(StringVariable))
             {
                 StringVariable stringVariable = (variable as StringVariable);
                 condition = stringVariable.Evaluate(compareOperator, stringData.Value);
             }
-            else if (variable.GetType() == typeof(AnimatorVariable))
+            else if (t == typeof(AnimatorVariable))
             {
                 AnimatorVariable animatorVariable = (variable as AnimatorVariable);
                 condition = animatorVariable.Evaluate(compareOperator, animatorData.Value);
             }
-            else if (variable.GetType() == typeof(AudioSourceVariable))
+            else if (t == typeof(AudioSourceVariable))
             {
                 AudioSourceVariable audioSourceVariable = (variable as AudioSourceVariable);
                 condition = audioSourceVariable.Evaluate(compareOperator, audioSourceData.Value);
             }
-            else if (variable.GetType() == typeof(ColorVariable))
+            else if (t == typeof(ColorVariable))
             {
                 ColorVariable colorVariable = (variable as ColorVariable);
                 condition = colorVariable.Evaluate(compareOperator, colorData.Value);
             }
-            else if (variable.GetType() == typeof(GameObjectVariable))
+            else if (t == typeof(GameObjectVariable))
             {
                 GameObjectVariable gameObjectVariable = (variable as GameObjectVariable);
                 condition = gameObjectVariable.Evaluate(compareOperator, gameObjectData.Value);
             }
-            else if (variable.GetType() == typeof(MaterialVariable))
+            else if (t == typeof(MaterialVariable))
             {
                 MaterialVariable materialVariable = (variable as MaterialVariable);
                 condition = materialVariable.Evaluate(compareOperator, materialData.Value);
             }
-            else if (variable.GetType() == typeof(ObjectVariable))
+            else if (t == typeof(ObjectVariable))
             {
                 ObjectVariable objectVariable = (variable as ObjectVariable);
                 condition = objectVariable.Evaluate(compareOperator, objectData.Value);
             }
-            else if (variable.GetType() == typeof(Rigidbody2DVariable))
+            else if (t == typeof(Rigidbody2DVariable))
             {
                 Rigidbody2DVariable rigidbody2DVariable = (variable as Rigidbody2DVariable);
                 condition = rigidbody2DVariable.Evaluate(compareOperator, rigidbody2DData.Value);
             }
-            else if (variable.GetType() == typeof(SpriteVariable))
+            else if (t == typeof(SpriteVariable))
             {
                 SpriteVariable spriteVariable = (variable as SpriteVariable);
                 condition = spriteVariable.Evaluate(compareOperator, spriteData.Value);
             }
-            else if (variable.GetType() == typeof(TextureVariable))
+            else if (t == typeof(TextureVariable))
             {
                 TextureVariable textureVariable = (variable as TextureVariable);
                 condition = textureVariable.Evaluate(compareOperator, textureData.Value);
             }
-            else if (variable.GetType() == typeof(TransformVariable))
+            else if (t == typeof(TransformVariable))
             {
                 TransformVariable transformVariable = (variable as TransformVariable);
                 condition = transformVariable.Evaluate(compareOperator, transformData.Value);
             }
-            else if (variable.GetType() == typeof(Vector2Variable))
+            else if (t == typeof(Vector2Variable))
             {
                 Vector2Variable vector2Variable = (variable as Vector2Variable);
                 condition = vector2Variable.Evaluate(compareOperator, vector2Data.Value);
             }
-            else if (variable.GetType() == typeof(Vector3Variable))
+            else if (t == typeof(Vector3Variable))
             {
                 Vector3Variable vector3Variable = (variable as Vector3Variable);
                 condition = vector3Variable.Evaluate(compareOperator, vector3Data.Value);
@@ -209,70 +211,72 @@ namespace Fungus
                 return "Error: No variable selected";
             }
 
+            var t = variable.GetType();
+
             string summary = variable.Key + " ";
             summary += Condition.GetOperatorDescription(compareOperator) + " ";
 
-            if (variable.GetType() == typeof(BooleanVariable))
+            if (t == typeof(BooleanVariable))
             {
                 summary += booleanData.GetDescription();
             }
-            else if (variable.GetType() == typeof(IntegerVariable))
+            else if (t == typeof(IntegerVariable))
             {
                 summary += integerData.GetDescription();
             }
-            else if (variable.GetType() == typeof(FloatVariable))
+            else if (t == typeof(FloatVariable))
             {
                 summary += floatData.GetDescription();
             }
-            else if (variable.GetType() == typeof(StringVariable))
+            else if (t == typeof(StringVariable))
             {
                 summary += stringData.GetDescription();
             }
-            else if (variable.GetType() == typeof(AnimatorVariable))
+            else if (t == typeof(AnimatorVariable))
             {
                 summary += animatorData.GetDescription();
             }
-            else if (variable.GetType() == typeof(AudioSourceVariable))
+            else if (t == typeof(AudioSourceVariable))
             {
                 summary += audioSourceData.GetDescription();
             }
-            else if (variable.GetType() == typeof(ColorVariable))
+            else if (t == typeof(ColorVariable))
             {
                 summary += colorData.GetDescription();
             }
-            else if (variable.GetType() == typeof(GameObjectVariable))
+            else if (t == typeof(GameObjectVariable))
             {
                 summary += gameObjectData.GetDescription();
             }
-            else if (variable.GetType() == typeof(MaterialVariable))
+            else if (t == typeof(MaterialVariable))
             {
                 summary += materialData.GetDescription();
             }
-            else if (variable.GetType() == typeof(ObjectVariable))
+            else if (t == typeof(ObjectVariable))
             {
                 summary += objectData.GetDescription();
             }
-            else if (variable.GetType() == typeof(Rigidbody2DVariable))
+            else if (t == typeof(Rigidbody2DVariable))
             {
                 summary += rigidbody2DData.GetDescription();
             }
-            else if (variable.GetType() == typeof(SpriteVariable))
+            else if (t == typeof(SpriteVariable))
             {
                 summary += spriteData.GetDescription();
             }
-            else if (variable.GetType() == typeof(TextureVariable))
+            else if (t == typeof(TextureVariable))
             {
                 summary += textureData.GetDescription();
             }
-            else if (variable.GetType() == typeof(TransformVariable))
+            else if (t == typeof(TransformVariable))
             {
                 summary += transformData.GetDescription();
             }
-            else if (variable.GetType() == typeof(Vector2Variable))
+            else if (t == typeof(Vector2Variable))
             {
                 summary += vector2Data.GetDescription();
             }
-            else if (variable.GetType() == typeof(Vector3Variable))
+            else if (t == typeof(Vector3Variable))
             {
                 summary += vector3Data.GetDescription();
             }
@@ -282,7 +286,77 @@ namespace Fungus
 
         public override bool HasReference(Variable variable)
         {
-            return (variable == this.variable);
+            bool retval = (variable == this.variable) || base.HasReference(variable);
+
+            var t = variable.GetType();
+
+            //this is a nightmare
+            if (t == typeof(BooleanVariable))
+            {
+                retval |= booleanData.booleanRef == variable;
+            }
+            else if (t == typeof(IntegerVariable))
+            {
+                retval |= integerData.integerRef == variable;
+            }
+            else if (t == typeof(FloatVariable))
+            {
+                retval |= floatData.floatRef == variable;
+            }
+            else if (t == typeof(StringVariable))
+            {
+                retval |= stringData.stringRef == variable;
+            }
+            else if (t == typeof(AnimatorVariable))
+            {
+                retval |= animatorData.animatorRef == variable;
+            }
+            else if (t == typeof(AudioSourceVariable))
+            {
+                retval |= audioSourceData.audioSourceRef == variable;
+            }
+            else if (t == typeof(ColorVariable))
+            {
+                retval |= colorData.colorRef == variable;
+            }
+            else if (t == typeof(GameObjectVariable))
+            {
+                retval |= gameObjectData.gameObjectRef == variable;
+            }
+            else if (t == typeof(MaterialVariable))
+            {
+                retval |= materialData.materialRef == variable;
+            }
+            else if (t == typeof(ObjectVariable))
+            {
+                retval |= objectData.objectRef == variable;
+            }
+            else if (t == typeof(Rigidbody2DVariable))
+            {
+                retval |= rigidbody2DData.rigidbody2DRef == variable;
+            }
+            else if (t == typeof(SpriteVariable))
+            {
+                retval |= spriteData.spriteRef == variable;
+            }
+            else if (t == typeof(TextureVariable))
+            {
+                retval |= textureData.textureRef == variable;
+            }
+            else if (t == typeof(TransformVariable))
+            {
+                retval |= transformData.transformRef == variable;
+            }
+            else if (t == typeof(Vector2Variable))
+            {
+                retval |= vector2Data.vector2Ref == variable;
+            }
+            else if (t == typeof(Vector3Variable))
+            {
+                retval |= vector3Data.vector3Ref == variable;
+            }
+
+            return retval;
         }
 
         public override Color GetButtonColor()
diff --git a/Assets/Fungus/Scripts/Commands/Wait.cs b/Assets/Fungus/Scripts/Commands/Wait.cs
index 6299217c..5c506688 100644
--- a/Assets/Fungus/Scripts/Commands/Wait.cs
+++ b/Assets/Fungus/Scripts/Commands/Wait.cs
@@ -41,6 +41,11 @@ namespace Fungus
             return new Color32(235, 191, 217, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _duration.floatRef == variable || base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Commands/WaitFrames.cs b/Assets/Fungus/Scripts/Commands/WaitFrames.cs
index a099b0eb..5d041945 100644
--- a/Assets/Fungus/Scripts/Commands/WaitFrames.cs
+++ b/Assets/Fungus/Scripts/Commands/WaitFrames.cs
@@ -49,6 +49,11 @@ namespace Fungus
             return new Color32(235, 191, 217, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return frameCount.integerRef == variable || base.HasReference(variable);
+        }
+
         #endregion
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Write.cs b/Assets/Fungus/Scripts/Commands/Write.cs
index 297df887..34ff445e 100644
--- a/Assets/Fungus/Scripts/Commands/Write.cs
+++ b/Assets/Fungus/Scripts/Commands/Write.cs
@@ -155,6 +155,11 @@ namespace Fungus
             return "WRITE." + GetFlowchartLocalizationId() + "." + itemId;
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return text.stringRef == variable || setAlpha.floatRef == variable || setColor.colorRef == variable || base.HasReference(variable);
+        }
+
         #endregion
     }
 }
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/iTweenCommand.cs b/Assets/Fungus/Scripts/Commands/iTweenCommand.cs
index 2bc8b0ac..b118b303 100644
--- a/Assets/Fungus/Scripts/Commands/iTweenCommand.cs
+++ b/Assets/Fungus/Scripts/Commands/iTweenCommand.cs
@@ -108,6 +108,12 @@ namespace Fungus
             return new Color32(233, 163, 180, 255);
         }
 
+        public override bool HasReference(Variable variable)
+        {
+            return _targetObject.gameObjectRef == variable || _tweenName.stringRef == variable ||
+                base.HasReference(variable);
+        }
+
         #endregion
 
         #region Backwards compatibility
diff --git a/Assets/Fungus/Scripts/Components/Command.cs b/Assets/Fungus/Scripts/Components/Command.cs
index 0c63df11..6188f3ea 100644
--- a/Assets/Fungus/Scripts/Components/Command.cs
+++ b/Assets/Fungus/Scripts/Components/Command.cs
@@ -50,6 +50,30 @@ namespace Fungus
 
         protected string errorMessage = "";
 
+        #region Editor caches
+#if UNITY_EDITOR
+        //
+        protected List<Variable> referencedVariables = new List<Variable>();
+
+        //used by var list adapter to highlight variables 
+        public bool IsVariableReferenced(Variable variable)
+        {
+            return referencedVariables.Contains(variable) || HasReference(variable);
+        }
+
+        /// <summary>
+        /// Called by OnValidate
+        /// 
+        /// Child classes to specialise to add variable references to referencedVariables, either directly or
+        /// via the use of Flowchart.DetermineSubstituteVariables
+        /// </summary>
+        protected virtual void RefreshVariableCache()
+        {
+            referencedVariables.Clear();
+        }
+#endif
+        #endregion Editor caches
+
         #region Public members
 
         /// <summary>
@@ -204,6 +228,16 @@ namespace Fungus
             return false;
         }
 
+        /// <summary>
+        /// Called by unity when script is loaded or its data changed by editor
+        /// </summary>
+        public virtual void OnValidate()
+        {
+#if UNITY_EDITOR
+            RefreshVariableCache();
+#endif
+        }
+
         /// <summary>
         /// Returns the summary text to display in the command inspector.
         /// </summary>
diff --git a/Assets/Fungus/Scripts/Components/Flowchart.cs b/Assets/Fungus/Scripts/Components/Flowchart.cs
index 28355e20..25b11047 100644
--- a/Assets/Fungus/Scripts/Components/Flowchart.cs
+++ b/Assets/Fungus/Scripts/Components/Flowchart.cs
@@ -1264,6 +1264,23 @@ namespace Fungus
             }
         }
 
+        public virtual void DetermineSubstituteVariables(string str, List<Variable> vars)
+        {
+            Regex r = new Regex(Flowchart.SubstituteVariableRegexString);
+
+            // Match the regular expression pattern against a text string.
+            var results = r.Matches(str);
+            for (int i = 0; i < results.Count; i++)
+            {
+                var match = results[i];
+                var v = GetVariable(match.Value.Substring(2, match.Value.Length - 3));
+                if (v != null)
+                {
+                    vars.Add(v);
+                }
+            }
+        }
+
         #endregion
 
         #region IStringSubstituter implementation
diff --git a/Assets/Fungus/Scripts/Editor/BlockEditor.cs b/Assets/Fungus/Scripts/Editor/BlockEditor.cs
index 5850dfd6..a010a3a2 100644
--- a/Assets/Fungus/Scripts/Editor/BlockEditor.cs
+++ b/Assets/Fungus/Scripts/Editor/BlockEditor.cs
@@ -62,18 +62,27 @@ namespace Fungus.EditorUtils
             serializedObject.Update();
 
             SerializedProperty blockNameProperty = serializedObject.FindProperty("blockName");
-            Rect blockLabelRect = new Rect(45, 5, 120, 16);
-            EditorGUI.LabelField(blockLabelRect, new GUIContent("Block Name"));
-            Rect blockNameRect = new Rect(45, 21, 180, 16);
-            EditorGUI.PropertyField(blockNameRect, blockNameProperty, new GUIContent(""));
-
-            // Ensure block name is unique for this Flowchart
-            var block = target as Block;
-            string uniqueName = flowchart.GetUniqueBlockKey(blockNameProperty.stringValue, block);
-            if (uniqueName != block.BlockName)
-            {
-                blockNameProperty.stringValue = uniqueName;
+            //calc position as size of what we want to draw pushed up into the top bar of the inspector
+            //Rect blockLabelRect = new Rect(45, -GUI.skin.window.padding.bottom - EditorGUIUtility.singleLineHeight * 2, 120, 16);
+            //EditorGUI.LabelField(blockLabelRect, new GUIContent("Block Name"));
+            //Rect blockNameRect = new Rect(45, blockLabelRect.y + EditorGUIUtility.singleLineHeight, 180, 16);
+            //EditorGUI.PropertyField(blockNameRect, blockNameProperty, new GUIContent(""));
+            EditorGUILayout.BeginHorizontal();
+            EditorGUILayout.PrefixLabel(new GUIContent("Block Name"), EditorStyles.largeLabel);
+            EditorGUI.BeginChangeCheck();
+            blockNameProperty.stringValue = EditorGUILayout.TextField(blockNameProperty.stringValue);
+            if(EditorGUI.EndChangeCheck())
+            {
+                // Ensure block name is unique for this Flowchart
+                var block = target as Block;
+                string uniqueName = flowchart.GetUniqueBlockKey(blockNameProperty.stringValue, block);
+                if (uniqueName != block.BlockName)
+                {
+                    blockNameProperty.stringValue = uniqueName;
+                }
             }
+            EditorGUILayout.EndHorizontal();
+            EditorGUILayout.Space();
 
             serializedObject.ApplyModifiedProperties();
         }
@@ -119,7 +128,8 @@ namespace Fungus.EditorUtils
 
                 SerializedProperty descriptionProp = serializedObject.FindProperty("description");
                 EditorGUILayout.PropertyField(descriptionProp);
-
+                EditorGUILayout.Space();
+                
                 DrawEventHandlerGUI(flowchart);
 
                 block.UpdateIndentLevels();
diff --git a/Assets/Fungus/Scripts/Editor/BlockInspector.cs b/Assets/Fungus/Scripts/Editor/BlockInspector.cs
index c27bb949..1ef5a062 100644
--- a/Assets/Fungus/Scripts/Editor/BlockInspector.cs
+++ b/Assets/Fungus/Scripts/Editor/BlockInspector.cs
@@ -28,7 +28,11 @@ namespace Fungus.EditorUtils
         protected Vector2 commandScrollPos;
         protected bool resize = false;
         protected bool clamp = false;
-        protected float topPanelHeight = 50;
+#if UNITY_2019_1_OR_NEWER
+        protected float topPanelHeight = 0;
+#else
+        protected float topPanelHeight = 48;
+#endif
         protected float windowHeight = 0f;
 
         // Cache the block and command editors so we only create and destroy them
@@ -96,18 +100,12 @@ namespace Fungus.EditorUtils
                 activeBlockEditor = Editor.CreateEditor(block) as BlockEditor;
             }
 
-            activeBlockEditor.DrawBlockName(flowchart);
-
             UpdateWindowHeight();
 
             float width = EditorGUIUtility.currentViewWidth;
-            float height = windowHeight;
-
-            // Using a custom rect area to get the correct 5px indent for the scroll views
-            Rect blockRect = new Rect(5, topPanelHeight, width - 5, height + 10);
-            GUILayout.BeginArea(blockRect);
 
             blockScrollPos = GUILayout.BeginScrollView(blockScrollPos, GUILayout.Height(flowchart.BlockViewHeight));
+            activeBlockEditor.DrawBlockName(flowchart);
             activeBlockEditor.DrawBlockGUI(flowchart);
             GUILayout.EndScrollView();
 
@@ -121,7 +119,6 @@ namespace Fungus.EditorUtils
                 inspectCommand != null &&
                 !inspectCommand.ParentBlock.Equals(block))
             {
-                GUILayout.EndArea();
                 Repaint();
                 return;
             }
@@ -143,21 +140,14 @@ namespace Fungus.EditorUtils
         /// </summary>
         protected void UpdateWindowHeight()
         {
-            EditorGUILayout.BeginVertical();
-            GUILayout.FlexibleSpace();
-            EditorGUILayout.EndVertical();
-            Rect tempRect = GUILayoutUtility.GetLastRect();
-            if (Event.current.type == EventType.Repaint)
-            {
-                windowHeight = tempRect.height;
-            }
+            windowHeight = Screen.height * EditorGUIUtility.pixelsPerPoint;
         }
 
         public void DrawCommandUI(Flowchart flowchart, Command inspectCommand)
         {
             ResizeScrollView(flowchart);
 
-            GUILayout.Space(7);
+            EditorGUILayout.Space();
 
             activeBlockEditor.DrawButtonToolbar();
 
@@ -191,11 +181,9 @@ namespace Fungus.EditorUtils
 
             GUILayout.EndScrollView();
 
-            GUILayout.EndArea();
-
             // Draw the resize bar after everything else has finished drawing
             // This is mainly to avoid incorrect indenting.
-            Rect resizeRect = new Rect(0, topPanelHeight + flowchart.BlockViewHeight + 1, Screen.width, 4f);
+            Rect resizeRect = new Rect(0, flowchart.BlockViewHeight + topPanelHeight, EditorGUIUtility.currentViewWidth, 4f);
             GUI.color = new Color(0.64f, 0.64f, 0.64f);
             GUI.DrawTexture(resizeRect, EditorGUIUtility.whiteTexture);
             resizeRect.height = 1;
@@ -210,19 +198,22 @@ namespace Fungus.EditorUtils
 
         private void ResizeScrollView(Flowchart flowchart)
         {
-            Rect cursorChangeRect = new Rect(0, flowchart.BlockViewHeight + 1, Screen.width, 4f);
+            Rect cursorChangeRect = new Rect(0, flowchart.BlockViewHeight + 1 + topPanelHeight, EditorGUIUtility.currentViewWidth, 4f);
 
             EditorGUIUtility.AddCursorRect(cursorChangeRect, MouseCursor.ResizeVertical);
             
-            if (Event.current.type == EventType.MouseDown && cursorChangeRect.Contains(Event.current.mousePosition))
+            if (cursorChangeRect.Contains(Event.current.mousePosition))
             {
-                resize = true;
+                if (Event.current.type == EventType.MouseDown)
+                {
+                    resize = true;
+                }
             }
 
-            if (resize)
+            if (resize && Event.current.type == EventType.Repaint)
             {
                 Undo.RecordObject(flowchart, "Resize view");
-                flowchart.BlockViewHeight = Event.current.mousePosition.y;
+                flowchart.BlockViewHeight = Event.current.mousePosition.y - topPanelHeight;
             }
             
             ClampBlockViewHeight(flowchart);
@@ -231,7 +222,7 @@ namespace Fungus.EditorUtils
             // This isn't standard Unity UI behavior but it is robust and safe.
             if (resize && Event.current.type == EventType.MouseDrag)
             {
-                Rect windowRect = new Rect(0, 0, Screen.width, Screen.height);
+                Rect windowRect = new Rect(0, 0, EditorGUIUtility.currentViewWidth, windowHeight);
                 if (!windowRect.Contains(Event.current.mousePosition))
                 {
                     resize = false;
@@ -259,7 +250,7 @@ namespace Fungus.EditorUtils
                 // Make sure block view is always clamped to visible area
                 float height = flowchart.BlockViewHeight;
                 height = Mathf.Max(200, height);
-                height = Mathf.Min(Screen.height - 200,height);
+                height = Mathf.Min(windowHeight - 200,height);
                 flowchart.BlockViewHeight = height;
             }
             
diff --git a/Assets/Fungus/Scripts/Editor/VariableListAdaptor.cs b/Assets/Fungus/Scripts/Editor/VariableListAdaptor.cs
index 3b3698cc..8dcfaf8c 100644
--- a/Assets/Fungus/Scripts/Editor/VariableListAdaptor.cs
+++ b/Assets/Fungus/Scripts/Editor/VariableListAdaptor.cs
@@ -178,7 +178,7 @@ namespace Fungus.EditorUtils
             {
                 if (Application.isPlaying && flowchart.SelectedBlock.IsExecuting())
                 {
-                    highlight = flowchart.SelectedBlock.ActiveCommand.HasReference(variable);
+                    highlight = flowchart.SelectedBlock.ActiveCommand.IsVariableReferenced(variable);
                 }
                 else if (!Application.isPlaying && flowchart.SelectedCommands.Count > 0)
                 {
@@ -189,7 +189,7 @@ namespace Fungus.EditorUtils
                             continue;
                         }
 
-                        if (selectedCommand.HasReference(variable))
+                        if (selectedCommand.IsVariableReferenced(variable))
                         {
                             highlight = true;
                             break;