tidy and better handling of auth and hostnames