Clarified some comments
Heavily refactored program code.
Updated comments and made the code more modular.