split out prime generation from code generation, don't correct if key generation fails