Finally works completely.

Fixes to the ip address gathering code