Apply patch from Christian Weisskopf