Rewrite some scripts

Signed-off-by: Yaroslav Eremin <Yaroslav@itwonline.ru>