Seriously simplify and correct the PHI node handling code.