Fix some bugs with globs and shadowing

r? eddyb