Refactor serde and ScalarValue relations
#985
+577
−765
Merged