Please, consider the attached patch, as it seems to solve the problem