Rewrite imports detection algorithm.