Brought over writing reduction from 746595735c2da7c51dc251e6f57c19acdb493784.