fixes #248
handle circular dependencies in a neater way