fixed various mistakes with types and field order