Apply patch from Sami Liedes <sliedes@cc.hut.fi> to reduce the