Renamed SafeSubstring param and supporting logic - v3

SafeSubstring was incorrectly passing "length" as "startIndex".