Refactor for better handling of local host.
Merged frostwire-common changes