fix problem in socket buffer tuning

and delete some now unused code
fix memory leak in protobuf usage