wip. applying a patch from a previous GSoC project.