Refactored import code a bit.