Fix compilation

Implement a default key generation function. This also uncomments some important code that was removed during debugging.