Encoding fixes and Connection Exception solution