converted to using the new socket wrapper.
improved debug logging.