CGL refactor -- don't know if it compiles