Not sure if 'retval' is a good name here, as this value is never actually returned as far as I can see.