sync with upstream, some fixes