Fix memory leak in generate_key wrapper. Other fixes.
am: d9b9295b8c

* commit 'd9b9295b8c2f17448f4eb3ea2c6f7d4a5c207c3f':
  Fix memory leak in generate_key wrapper. Other fixes.