Fixing issues with key creation