patched a few more upstream changes