Code improvements from Vincenzo