Bugfix - unclosed stream
1) refactoring
2) Now it's possible to pass command line params to a script