Fixes for PP generation and ensure_immutable_contig