Improved support for recursive imports

* Fix exponential performance complexity for recursive imports
* Fix #707