Fix memory leaks and finalise @PG PP handling
Test @PG merging and PP handling