Handle --list and --dns, slight refactor