add some logging for connect and disconnect
fix a potential deadlock, change totalmessages to atomiclong
add tostring
disconnect log message
update build