cleaned up keygen