CGL changes and bugfixes backported from master

Change-Id: Ifd6a8e41cc51661dcfaa7854578fd8cc1b661f33