SW-39. Fix from Giuseppe Ribezzo and minor changes.