patched in upstream changes