improve error gesture in network part
Cleanup code and fix memory alloc.
work on tests