tidy up make files, simplify namespaces, rework tcp event loop