Made refactoring and added javadoc.
Made refactoring and added javadoc.