Fix thin queries.
Add initial support for IPv6.