Detect host name more correctly