Minor performance tweaks on serialization