removed self made singleton code and used call_once.
fixed some memory leaks
added estimateSize for the packet buffer