fix bugs in env.