Backport of LayerGroup patch for branch 1.5.x

Hi,
I've backported the latest LayerGroup patch on branch 1.5.x