Increased MAX_TYPE3_REPEAT to 40 (as per 1.298). This should really be revised with a dynamic memory approach.