sync with upstream. [hackish/wip]