Merged changes from upstream

(see commit messages)