PR comments - refactoring

Refactor usage of DNS. Remove some copy-paste mistakes. Improve error messages.