fixed env to env_map and added hostfile logic.