Add missing docstrings
Refactor by moving the circular import loop control at the right level
More readable version of the code