Improve serialization / deserialization for SB