Re-organized code for PCL