Refactor hostname usage