Reimplement PPM metadata reading to avoid buffer overflows