Fix some bugs. Indexes, iterations and close stream.
Merge branch 'master' of https://github.com/SergeyRyzhov/VSS