Works again, but ugly implementation.
Disconnect is now more fault-tolerant.
fix invalid return
Remove debug code.