Updated to better handle hostnames.