should fixe IPv6 issues (clean Jeff Poskanser's code)