Adding message serialization and socket read/write stuff.