Possible fix (ugly hack) for issue #2509

Please do not yet merge this one, it is to find the best solution