moved common routines in script folder, minor fixes