Fix bug in handling of environment directives.