Merge changes from upstream

Merge a bunch of little fixes from upstream.