fix reported bugs by Didier Cadet