Manually merged in #1895.