Add GenerateKey

Also add some more documentation.