Optimizing PFSMs