Fixes for tcp IO and serialization