Apply pull #507 manually