Refactored code that builts HostInfo and removed repetition.