Add the environment variables
Fix some bugs