Fixes and upgrades to PCFG and FunctionNode