Move marshalling to separate file