Convert PG and RG pseudo code to working code.
Add pseudocode for PG PP: translation.