Some tweaks to work with with IPv6 enabled servers

This merge fixes things on web servers with IPv6 enabled and should work fine on legacy IPv4 as well.