add qnikst`s solution

+ fix access violation error found by anonymous
+ speedup fix (remote length check)
+ Speedup calculate length of the in strict only if required and cache
  result
anon_strcut added
Merge pull request #3 from qnikst/master

fixes and solution from anonymous