Merge upstream

Merged upstream changes since forked.