added a close connection on broken pipe and added additional debug
merged