Handling hostname and protocol better for all environments.