fix critical bug which allowed use any character in hostnames. Also, fixes #20