added more encoding/decoding functions. Added New func for version msg. Made encode/decode of structs methods instead of funcs. minor tweaks.