improved logging, fixed bugs in connection event handling