lot of corrections proposed by mdemierre in #165