Several fixes

Mauro: several fixes with respect to the first version.