refactor -source-env, remove useless helper functions