fixed hostname with dash
copy more changes from python2 to python3