Upstream rebase

All the latest stuff from upstream.