Fixed environment handling bug.