Refactored some scripts.

Signed-off-by: Tihomir Gvero <tihomir.gvero@gmail.com>