Improve DNS resolution & refactoring