Fix initialization order problem in generated code