move debug.h to common/
improve connecting
remove support for async cancel
general code cleanup