Import patch from Gustavo Niemeyer