sync with upstream patches