Switch to debruijn indices, genericize sub/lub/glb

More refactoring in support of HRTB. There should be no change in functionality from these changes.

r? @pnkfelix 
> Bruijn

Thanks! and I was being so careful to always spell it right :)