Keygen functions fixed