remove unusued code; fix s3 inf looping; move env var list to top of code