Move environment setting to pre2.js
Refactor and cleanup reporting calls step 1