Fix env and add output redirection.