Apply patch by Christophe Troestler