Changes err to retval.