Move serialization logic to utils
Merge master