Reorganization and optimization of CL related functions