Fixed bugs in PFD, improved performance