Allow for port forwarding, and fixes to hostnames
fix strange condition with empty ports string.