Loop in run.sh and minor fixes