Re-implement path import optimization