Patch from Lorenzo to fix previous incomplete patch.