Refactor import(), optimize