Patched from master.