improve addnodes and addreferences struct and serialization

It is not finished but current version makes wireshark happy and does not break anything. I tried to implement your comments. ok now?