Debug and cleanup case statements, tweaked exist statements and update shell scripts