Updated check to avoid re-setting shortest variables unnecessarily.  Added a few test cases to exercise this.