Some variable naming consistency would be good.  It's called pfunc, pf, and func in various places.  I think just func would be good everywhere.