improve encoding decoding of structures containing arrays