Merging Pierre Ganty's fixes.