Massive cleanup of the shell script. Many issues were fixed. Signed-off-by: Rosen Penev <rosenp@gmail.com> (cherry picked from commit c61614a849)
c61614a849