Fix dependency-injected variable scope