simplified code (need automatic testing) - added primitive new format support.