Fix for undefined 'res', which seems to be not easily reproducable.