Remove repeated marshalling logic

Adds a Marshaller class that can store errors
Remove unnecessary to_data method