Refactor gdw.sh with error checking, not done.