Fixed environment to also build environment for functions