better generation of structs, recursively typecheck if a struct is valid