Applying patch from A. Ivakhnenko