Patch to solve this bug, provided by Sergio Ahumada