Refactoring & enabling hostname and port setup for client