Fixed dependency extractor to avoid infinite loops