Refactoring, added JavaDocs, resolved some code quality problems.