updated javadocs and refactored a bit