Applied patch to fix some upstream bugs