Thanks to Berker Peksag for the patch. Backport of 4f11b7362206224ad876018bba19b7c9a08b7f0b from master.