how to get a clean AC current waveform for power-factor calculations
If you have the ability to sample your voltage and current signals then computing the power factor might be easier than trying to measure it directly.  To do this, compute the RMS voltage and current for a cycle.  The Apparent Power will be equal to the product of the RMS voltage and current.  At the same time, compute the True Power consumed over the same cycle by summing the Instantaneous Power.  Once you have the Apparent Power and the True Power, you have two sides of the Power Triangle.  True Power is equal to Apparent Power times the cosine of the power factor.  Solve for the power factor.