Refactor RSA code.