Fixed logic to scan subdirectories for imports