Gabriel Vasseur's patch, corrected just enough for it to compile.