Cleans up and fixes adding of ips and/or ports

Better way of doing things.
A bit of code clean up while I am at it.