Improved ipv4\/ipv6 detection