fix for nested uses of stencils

Not sure it's the right fix, but it fixes examples such as https://gist.github.com/e1fbe5bc1982e9bb1aaf for me, reviews welcome.