add duplex peer'ing, fix more memory leaks.

[going from golang to C is not fun]