Corrected functionality, refactored code, improved JavaDocs.