localize some imports

This one will obviously be different, as it's already merged, but aren't imports usually declared at the start of the inner-most scope where they're used, rather than right before they're used?