Fixed serialization to be more efficient and accept AvroRecord trait defined classes.