handling of host and port stuff (not sure if this is the right way to do it....)