Rewritten to work with IPv6