Backport changes from master