catch and handle circular dependencies. fixes #1.