RSA: refactored and added some javadocs