Serialization rework

I'd like to merge this first part, before COSerialization diff becomes too unreadable. I split/moved few pieces of code in COSerialization, and it looks like the diff result doesn't track them very well, sorry. 

I also have more COSerialization changes coming, currently kept in a private branch.

I'll start writing some tests this afternoon probably, or next week since I'm going to be away until next Monday this week-end.