Move all hostname processing into Connection class.

Better encapsulation and flexability in future.