Duplicate changes from #1321