Upstream changes

Upstream changes but with conflicts resolved.