Fix errors and env.sh file creation