Backport of changes from indigo branch