Code refactoring was performed. Javadocs were added.