Refactor for better handling of local host.