RSA refactoring