ipv6 support, and several bugfixes along the way. fix #2641