Merge upstream changes

Merge in all the changes from upstream. Tests still seem to pass, and give a good place to start writing tests around the AES functionality from.