Fixed recursive reference resolver.