Improve memory management when decoding.