Fix bug in saving hostnames