Semi-working solution, for case classes with only primitive fields.