Aes wip

Please see the comments against each commit for changes made.