cleanup
added better diagnostic in case of bad socket connection