update scripts

* add comments
* smal fixes and optimation