Refactored for user-friendliness, added more extensive code comments and JavaDocs