Fixes for key generation