Fix nasty dynamic scope bug