refactor env.init to init.files
misc refactoring