fixes from Sergio audit report