some improvements to resolve_ip()