Fixed issue with circular dependencies in referenced documents