Implement scoped environment.