Merge upstream changes

Pulls in patches from upstream, feel free not to merge yet. Setting this as the base for playing with adding some things for Aja.