Fix handling of circular dependencies that occur outside of direct depen...

...dencies