Apply first part of Thierry's patches