Fix encoding of optional elements
Fix enumeration encoding