Added more error control. Added domain name resolution